- Print Date:
- Sep 25, 2016 8:15:02 PM
Blog: Avoid Costly Mistakes and Confusion - Colored Prompt Tip
I thought I'd share a little trick for my fellow Linux users. Some of you may already know this but it's very helpful for me when SSH'ing from development to live servers, so I don't make any mistakes. This trick will allow you to change the color of your prompts for each individual server.
For this trick to work, you simply edit your bashrc file on whatever server you want to change the color of your prompt. Some general steps if you're not familiar:
1) Use your favorite editor to edit your bashrc file:
2) Comment out the default setting for PS1:
#PS1='[\u@\h \W]\$ '
3) Add (this is my setting for a user, it's pink ;) ):
for Root settings:
PS1='\[\e[0;31m\]\u \[\e[1;34m\]\w \[\e[0;31m\]\$ \[\e[0;32m\] '
Here's a list of different colors:
Black-0;30 Dark Gray-1;30 Blue-0;34 Light Blue-1;34 Green-0;32 Light Green-1;32 Cyan-0;36 Light Cyan-1;36 Red-0;31 Light Red-1;31 Purple-0;35 Light Purple-1;35 Brown-0;33 Yellow-1;33 Light Gray0;37 White-1;37
4) Keep repeating these steps on your desired servers with your preference of color.
5) For the colors to take effect you have to either restart your console or source your bashrc file:
or if your last command was to edit the bashrc file you can use bang-dollar (which saves me a lot of time if I'm dealing with the same file a lot):
I know this helps me out a lot, so I hope this helps others to avoid mistakes and improves the efficiency of your work!