Thursday, October 2, 2008

Lost in a sea of terminals

Usually I enjoy my screen being covered with a variety of terminals across multiple servers. But on occasion, I type utterly the wrong thing, in utterly the wrong place, and calamity ensues.

So to provide a slight buffer against this, I made a change in my bash prompt. It clues me in if I am on a remote server, a non-personal machine if you will, on which I need to exercise more caution before beating the enter key:
Just something noticeable, but not overly intrusive. Won't stop idiocy, of course, but it can't hurt.

To make it work:

# Prompt with easier to read coloring. Define and check for safe boxes:
declare -a LOCALBOXES[0]="MyBox1" LOCALBOXES[1]="MyBox2"
for box in $LOCALBOXES
if [[ $CURRENTBOX = $box ]] ; then
PS1="\[\033[0;31m\][\T]\[\033[0;36m\]\u@\[\033[1;33m\]\H \[\033[1;34m\]\w: \[\033[0m\]"
PS1="\[\033[1;36m\]**REMOTE**\[\033[0;31m\][\T]\[\033[0;36m\]\u@\[\033[1;33m\]\H \[\033[1;34m\]\w: \[\033[0m\]"