Different color prompts for different machines when using terminal/ssh?

Posted by bcrawl on Server Fault See other posts from Server Fault or by bcrawl
Published on 2011-01-11T13:37:48Z Indexed on 2012/09/09 3:40 UTC
Read the original article Hit count: 492

Filed under:
|

I have 5 machines I constantly ssh into to do work. Its getting increasingly frustrating when I am issuing wrong commands on wrong boxes. Luckily I havent done anything bad yet. I wanted to know if there is any hack which I can hardcode which will display my prompt in different colors based on the machine I am ssh into? Such as blue for desktop1, purple for laptop, red for server etc? Is this possible?

Currently I am using this command export PS1="\e[0;31m[\u@\h \W]\$ \e[m " taken from here http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/ but it obviously doesnt work across ssh.

Also, if you have any other cool bash tips for helping me ease my sight will be wonderful. I got this tip which colors the man pages.

http://linuxtidbits.wordpress.com/2009/03/23/less-colors-for-man-pages/

© Server Fault or respective owner

Related posts about bash

Related posts about command-prompt