Conditional Prompt colo(u)rs

December 23, 2009

I often work on several different machines, for different projects and things. It’s bloody annoying when I get the wrong machine!

I thought. I know what, I’ll make all of these machines use a colored prompt, and make that lot of machines use a different one.

(At this point, I should say that my dotfiles, and a variety of other things are kept in a subversion repo. Most of those bits are my-eyes-only (particularly a lot of the very badly/hastily thrown together scripts), but a few bits I’m gradually releasing.)

After mentioning this on twitter, a couple of people have been interested in how I did it.

The solution is quite easy, work out the hostname, and from that determine the ‘class’ of machine, and then apply some colors. The archwiki was useful in getting out the colors to use; along with underlining, and emboldening (I never use underlining, except in manuscript: ghastly thing that obscures text).

Whilst not perfect (the color parts could be set as a variable, and then passed to the PS1 line; I could have used “else” clauses…), it works. For me, so, erm, here’s my .bashrc — you want from the # work out machine name/domain: line.

A simple switch wotsits in screen(1), and

$ cd ~/pseudohome && svn up

followed with a

$ . .bashrc

is how I deploy (some people have an ‘svn up’ in their start-up scripts, I don’t).

Comments here, if you want to.

Some notes on LetsEncrypt

I've been playing with LetsEncrypt for a bit now, and on the whole, I like it. However, it's still early days, and I wanted to share my e...… Continue reading

Bloody Twitter

Published on December 02, 2013