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:

1
2
3
4
5
6
7
8
9
10
11
# Prompt with easier to read coloring.
# Define and check for safe boxes:
declare -a LOCALBOXES[0]="MyBox1" LOCALBOXES[1]="MyBox2"
CURRENTBOX=`hostname`
for box in $LOCALBOXES do
   if [[ $CURRENTBOX = $box ]] ; then
       PS1="\[\033[0;31m\][\T]\[\033[0;36m\]\u@\[\033[1;33m\]\H \[\033[1;34m\]\w:\[\033[0m\]"      
   else
       PS1="\[\033[1;36m\]**REMOTE**\[\033[0;31m\][\T]\[\033[0;36m\]\u@\[\033[1;33m\]\H \[\033[1;34m\]\w: \[\033[0m\]"
   fi
done

Post to Twitter Post to Delicious Post to Digg Post to Reddit

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

This entry was posted in CLI, Desktop and tagged , . Bookmark the permalink.

2 Responses to Lost in a sea of terminals

  1. mray says:

    I like to use a little color to warn myself when I’m root:

    PS1=”\h:\$(date +%H:%M):\w
    \[\033[1;41m\]\[\033[1;37m\]ROOT\033[0m # “

  2. by Immortal Curiosity says:

    That sounds like a good idea, but I try never to have to work as root on a server:-)

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>