The only terminal emulators I'm aware of that conveniently support it out of the box are xfce4-terminal
and konsole
.
Terminator version 1.90 and above (actually its underlying VTE widget), however, understands the OSC 11 escape sequence to change the background color, e.g.:
echo -ne '\e]11;#abcdef\a'
(and similarly with 10
for foreground).
You might write a chunk of shell script that randomizes the color and emits this sequence from the shell startup script (e.g. .bashrc
). Take care to emit it only if the shell is interactive and/or its output is connected to a terminal (see e.g. here).
A quick example, I leave it up to you to improve as you wish:
if [ -t 1 ]; then
colors=(abcdef cdefab efabcd)
n=${#colors[@]}
i=$((RANDOM%n))
echo -ne "\e]11;#${colors[i]}\a"
fi
Instead of a random number, it might be a good idea to base the color on the tty line (the number from the output of tty
), that way you'll have fewer conflicts.