0

One of my favorite features of the xfce terminal is that it can automatically set a different color for each terminal instance the user creates. This makes it very easy to differentiate between the different sessions.

Is there any way to achieve a similar sort of functionality in Terminator?

1 Answer 1

1

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.

1
  • Thank you for your help @egmont! Unfortunately my rep is not high enough on this part of Stack to upvote your answer, but I appreciate your reply!
    – Spectator6
    Feb 9, 2018 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.