set GNU screen background color

Posted on

Problem :

I would like screen to change the background color of the terminal (xterm) when started.

I want to have a quick way of determining whether I am in screen or not. I often work over shh and it often crashes. I started using screen so as not to lose my work. However, I do not want screen to start automatically when I ssh to the machine because I probably want to do screen -list or screen -r instead. Therefore, I need something to alert me that I am not in screen and that my work (especially running applications) can be lost if the connection dies.

I have xterm and I use ssh -XY, if that is relevant.

Solution :

This doesn’t change the background color, but I have a screenrc file which will put a status line at the bottom which makes it obvious when you’re in screen:

As a gist:

# Turn off that annoying start up message
startup_message off

# Turn the even more annoying whole-screen-flash-on-tab-complete "feature"
vbell off

terminfo xterm-color hs@:cs=E[%i%p1%d;%p2%dr:im=E[4h:ei=E[4l
term xterm-color

# Window list at the bottom. hostname, centered tabs and redmarked active windows:
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'

Leave a Reply

Your email address will not be published. Required fields are marked *