I generally have several terminal windows open, and like them to have different background colors. I wrote this script to automatically rotate background colors as I launch new urxvt terminal instances.
#!/bin/bash
##
## rotate background colors in succesive launchings of urxvt terminal
##
## The preferred colors, and how many there are
colors=( "#ede1bb" "#dadad0" "#ffffdd" "#ced9d3" "#a8a892" "#ffe0cc")
ncolors=${#colors[*]}
# Keep track of most recent color choice via this file
COLORFILE=~/.colorchoice
if [ ! -f "$COLORFILE" ]
then
echo COLORCHOICE=0 > $COLORFILE
fi
source $COLORFILE ## read the most recently used color
## choice is an index into the colors array
let "choice = (1 + $COLORCHOICE) % $ncolors" ## increment previous choice, modulo ncolors
echo COLORCHOICE=$choice > $COLORFILE ## update global state
urxvt +sb -bg ${colors[$choice]} ## The +sb option kills the scrollbar

Posts