You are not logged in.
Hi all,
This has probably already been done, but I couldn't find anything similar so I though I would share it just in case...
Just a quick and dirty script to load term color settings from a Xresources-like file containing "color: xx" settings. So far only tested with ZSH and URxvt.
It just provides a lazy alternative to using 'xrdb -merge xxx' and opening a new console each time you want to try out a new theme.
Example usage:
$ colortest ~/.termcolors/theme1
Github: https://github.com/khughitt/dotfiles/tr … /colortest
Cheers,
Keith
#
# Sets the term colors to those specified in a .Xresources, etc. file
# for testing new color themes.
#
# Keith 2014/05/14
# https://github.com/khughitt/dotfiles/tree/master/bin/colortest
#
# if a file was specified, attempt parse colors and set terminal to those
# colors
if [ -n "$1" ]; then
infile=$1
echo 'Loading colors from ${infile}...'
function setColor() {
color=$1
# get hex color from file
hex=$(grep "color${color} *:" $infile | grep -v "^\!" | \
grep --color='never' -Eo "#[a-zA-Z0-9]{6}")
# convert to RGB triplet (0-1000)
red=$(printf "%.0f" $(( $(echo 0x${hex:1:2}) / 255.0 * 1000 )))
green=$(printf "%.0f" $(( $(echo 0x${hex:3:2}) / 255.0 * 1000 )))
blue=$(printf "%.0f" $(( $(echo 0x${hex:5:2}) / 255.0 * 1000 )))
# set color
tput initc $color $red $green $blue
}
for i in {0..15}; do
setColor $i
done
fi
Keith
dotfiles
Offline
If you use .Xdefaults instead of .Xresources, URxvt parses this every time it starts & no "xrdb -merge" is needed
Para todos todo, para nosotros nada
Offline
Wow, I always manage to completely forget about tput. I wrote a similar script in bash that involved quite a bit of painful mucking around with xterm esc sequences (https://gist.github.com/jsks/11323851), but at least it will automatically restore the original theme.
Offline
Thank you very much for this, I was looking for a way to do exactly this just the other day.
Offline