Have you ever been swapping between a Production and Staging environment when suddenly you make a change, but aren’t sure which pool you’re playing in anymore? It doesn’t happen often, but late nights and too many cups of coffee can lead to issues if you have your fingers in multiple environments. Adding a small script to your /etc/profile.d/ directory can help avoid making changes to the wrong system. I created a command.sh in the /etc/profile.d/ directory with the following information:
Production:
# added by Kristopher to differentiate between staging and production environments.
# staging command prompt will show green on a blue background where production will flash yellow on a red background.
# may the odds be ever in your favor.
PS1='\[\e[1;5;41;33m\]**PRODUCTION**\[\e[0m\][\u@\h \W]\$ '
Which ended up looking like this, but with the **PRODUCTION** text flashing:
Staging:
# added by Kristopher to differentiate between staging and production environments.
# staging command prompt will show green on a blue background where production will flash red on a yellow background.
# may the odds be ever in your favor.
PS1='\[\e[1;44;32m\]**STAGING**\[\e[0m\][\u@\h \W]\$ '
Which looked like:
There are really a countless number of options that you can use when changing the format of your command prompt! For more information and different options, these are the links I used to research the syntax for what I wanted:
http://blog.twistedcode.org/2008/03/customizing-your-bash-prompt.html
http://blog.superuser.com/2011/09/21/customizing-your-bash-command-prompt/
https://wiki.archlinux.org/index.php/Color_Bash_Prompt
If you have any questions, leave a comment or hit me up on twitter @goestocollege!!