Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: can zsh set background color?



> Is there any way for zsh to set the background color of my terminal 
> program?
> 
> I'm often logged into to 3 different computers (ssh), and it would be 
> handy to be able to quickly look for the color of one to know that it 
> was the one where I was connected to X
> 
> TjL
> Zsh 4.1.1 on Mac OS X
> 

As has been discussed, you'll need a terminal program that accepts escape
codes to change the background color. But if you find that, you might be
interested in my solution, which is to hash the hostname and generate
a color from the result. I get a probably-different background color
every time I connect to a new host.

My code is on http://zshwiki.org/WishList and repeated here:

# tint the terminal for each host
bgcolor=`hostname | md5sum | /usr/local/bin/python -c "c1=raw_input(); col=[int(c1[x:x+2],16) for x in 0,2,4]; print '#%02x%02x%02x'%tuple([40*x/max(col) for x in col])"`
print "\x1b]49;$bgcolor\x07"



Messages sorted by: Reverse Date, Date, Thread, Author