Skip to content

Instantly share code, notes, and snippets.

@jflemer
Created October 20, 2012 22:00
Show Gist options
  • Save jflemer/3924977 to your computer and use it in GitHub Desktop.
Save jflemer/3924977 to your computer and use it in GitHub Desktop.
Convert solarized PuTTY colors to gnome-terminal colors
#!/bin/sh
# Print solarized color tables
solarized="base03 base02 base01 base00 base0 base1 base2 base3 yellow orange red magenta violet blue cyan green"
base03_xterm=234
base02_xterm=235
base01_xterm=239
base00_xterm=240
base0_xterm=244
base1_xterm=245
base2_xterm=187
base3_xterm=230
yellow_xterm=136
orange_xterm=166
red_xterm=124
magenta_xterm=125
violet_xterm=61
blue_xterm=33
cyan_xterm=37
green_xterm=64
base03_ansi="1;30"
base02_ansi=30
base01_ansi="1;32"
base00_ansi="1;33"
base0_ansi="1;34"
base1_ansi="1;36"
base2_ansi=37
base3_ansi="1;37"
yellow_ansi=33
orange_ansi="1;31"
red_ansi=31
magenta_ansi=35
violet_ansi="1;35"
blue_ansi=34
cyan_ansi=36
green_ansi=32
# 16-color
printf '\033[m%7s %7s' " " 'base03'
for bg in $solarized; do
b="${bg}_ansi"
b=`eval "echo \\$$b"`
echo $b | grep -q '1;' && continue
printf ' %7s' $bg
done
printf '\n'
for fg in $solarized; do
printf '%7s' $fg
f="${fg}_ansi"
f=`eval "echo \\$$f"`
printf '\033[m \033[%sm%7s' $f "$f"
for bg in $solarized; do
b="${bg}_ansi"
b=`eval "echo \\$$b"`
echo $b | grep -q '1;' && continue
b=`echo $b | sed s/3/4/`
printf '\033[m \033[%s;%sm%7s' $b $f "$b;$f"
done
printf '\033[m\n'
done
# 256-color approximations
printf '%7s %7s' " " 'base03'
for bg in $solarized; do
b="${bg}_xterm"
b=`eval "echo \\$$b"`
printf ' %7s' $bg
done
printf '\n'
for fg in $solarized; do
printf '%7s' $fg
f="${fg}_xterm"
f=`eval "echo \\$$f"`
printf '\033[m \033[38;5;%sm%7s' $f "$f"
for bg in $solarized; do
b="${bg}_xterm"
b=`eval "echo \\$$b"`
printf '\033[m \033[48;5;%s;38;5;%sm%7s' $b $f "$b;$f"
done
printf '\033[m\n'
done
#!/bin/sh
# Fetch PuTTY color scheme from solarized repo and use it
# to set gnome-terminal colors to match.
repo="https://raw.github.com/altercation/solarized/master"
MODE=${1:-dark}
PROFILE=${2:-Default}
putty=`curl -s -o - "$repo/putty-colors-solarized/solarized_$MODE.reg"`
colors=`echo "$putty" | perl -e '
while(<>) {
push @c, m/Colou?r\d+[\s="]*?(\d+,\d+,\d+)/g;
}
print join(":", map { @a=split/,/,$_; sprintf("#%02x%02x%02x%02x%02x%02x", @a[0,0,1,1,2,2]) } @c);'`
fg=`echo $colors | cut -d : -f 1`
fg_bold=`echo $colors | cut -d : -f 2`
bg=`echo $colors | cut -d : -f 3`
palette=`echo $colors | awk -F : 'OFS=FS {print $7,$9,$11,$13,$15,$17,$19,$21,$8,$10,$12,$14,$16,$18,$20,$22}'`
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/$PROFILE/use_theme_colors false
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/$PROFILE/bold_color_same_as_fg false
gconftool-2 -s -t bool /apps/gnome-terminal/profiles/$PROFILE/allow_bold false
# set palette
gconftool-2 -s -t string /apps/gnome-terminal/profiles/$PROFILE/foreground_color "$fg"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/$PROFILE/bold_color "$fg_bold"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/$PROFILE/background_color "$bg"
gconftool-2 -s -t string /apps/gnome-terminal/profiles/$PROFILE/palette "$palette"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment