#!/bin/sh -e # Convert colours in my .Xresources from rxvt-unicode's format to pterm's. grep -v '^pterm.Colour' ~/.Xresources >~/.Xresources.$$ { seenBD=false grep '^Rxvt.' ~/.Xresources | while read label name ; do label="`echo "$label" | sed 's/^Rxvt.\(.*\):$/\1/'`" case "$label" in background) # 3 is bold background # 4 is text colour for cursor output="2 3 4" ;; foreground) # 1 is bold foreground output="0 1" ;; cursorColor) output="5" ;; color*) # 0 .. 7 :: 6, 8 .. 20 # 8 .. 15 :: 7, 9 .. 21 num="`echo "$label" | sed 's/color//'`" if [ "$num" -lt 8 ] ; then output="`expr \( $num \* 2 \) + 6`" else output="`expr \( \( $num - 8 \) \* 2 \) + 7`" fi ;; *) # Not a colour. continue ;; esac # This may be a reasonably useful trick to get the RGB value of an X # colour in sh. (I'm sure there's a better way...) vals=`ppmmake "$name" 1 1 | sed -e '1,3d' | od -vt 'u1' | head -1 | awk '{print $2 "," $3 "," $4}'` for o in $output ; do echo "pterm.Colour$o: $vals" done done } | sort -n -k1.13 >>~/.Xresources.$$ mv -f ~/.Xresources.$$ ~/.Xresources