termcolours

Automatically set unique terminal colour schemes

Background

If you’re someone who tends to run lots of terminals on different hosts at once, very occasionally, you will find yourself typing a command into the wrong window. This might lead to you, say, rebooting the wrong server, or dropping a table on the wrong database. This is all quite embarrassing, and best avoided.

A common strategy is to give each terminal window a different background colour. This makes it quicker to pick out the window you want, and has the bonus that it's a bit more obvious if you're typing into the wrong one.

People often make themselves a little menu to open new terminal windows on their most-used hosts. They hard code colours into here, hand picking them per host, or maybe using a colour for each application. This doesn't scale too well.

termcolours to the rescue!

It picks a colour for you based on the name of the host, so you don't have to worry about setting it up every time you install a new server. It only uses colours that give good contrast against the foreground text, and uses easy-on-the-eye ANSI colours from the Tango palette. It always uses the same colour for a given hostname, so when you're looking over a colleague's shoulder at a screenshare you get what you expect.

Screenshots

Install

Fedora and derivatives (Red Hat Enterprise Linux, etc.)

sudo dnf copr enable mavit/termcolours
sudo dnf install termcolours

From source

Download and unpack, then:

perl Makefile.PL
make
sudo make install

Lazy option

curl -o ~/.local/bin/termcolours https://bitbucket.org/mavit/termcolours/raw/release/script/termcolours
chmod +x ~/.local/bin/termcolours

Usage

echo termcolours >> ~/.bash_profile

For more detail, see the manual.

PuTTY

Additionally, set “Connection → Data → Terminal details → Terminal-type string” to putty-256color.