1

I have a dream: I want each virtual terminal within GNU Screen to have it's own unique background color.

I think I can fake it in an .bashrc script that emits xterm control codes to set background color based on the $WINDOW variable -- but this won't work if I kick off a non-bash process (ie. if I run "screen vi foo").

Is there a more clever way to accomplish a change in the background color every time I switch virtual terminals?

1 Answer 1

0

I'd love to be proven wrong but it does not appear possible with vt100 terminals, which is what screen emulates, to set their default background color; it is only possible, via a CSI sequence, to change the background color to its default value. It is possible though, providing your host terminal supports it, to send an OSC escape sequence to set the default background color. A consequence of setting the background color with this method though means that changes made to the background color in other screen windows is not preserved. In other words, if the host terminal background color is changed in one screen window, you then switch to a different window and change the default background color again, what you see when you switch back to the original screen window is the most recent background color change.

The following example .screenrc demonstrates a proof of concept. It works for konsole but is not practical since it requires each window to always be at a shell prompt where the proper sequence can be sent.

# start a few screen windows
screen 0
screen 1
screen 2
screen 3

# set up key bindings to set the host terminal bg color when you switch windows
# spawn the echo in a subshell to avoid displaying single quote/also need to quote the trailing backslash
bind 0 eval "select 0" "stuff \"(echo -n $'\eP\e]11;navy\cg\e\134\134\134\134') \012\""
bind 1 eval "select 1" "stuff \"(echo -n $'\eP\e]11;forestgreen\cg\e\134\134\134\134') \012\""
bind 2 eval "select 2" "stuff \"(echo -n $'\eP\e]11;slategray\cg\e\134\134\134\134') \012\""
bind 3 eval "select 3" "stuff \"(echo -n $'\eP\e]11;purple\cg\e\134\134\134\134') \012\""

# switch to the first window and set the background color to blue
eval "select 0" "stuff \"(echo -n $'\eP\e]11;navy\cg\e\134\134\134\134') \012\""

For the supported colors please reference the Qt documentation

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.