Skip to content

Change server terminal command prompt

If you deal with a lot of server, sometimes it can get tricky to keep track of which one you’re on…so a simple way to help that is to color code and name them in the command prompt.

All you need to do is:

  1. nano ~/.bashrc
  2. uncomment #force_color_prompt=yes
  3. Find a line like this:
    1
    
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  4. And Change it to something like this:
    1
    
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35;40m\]Staging \u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

For this I made it pink and added “Staging” before the hostname.  01;32m was the default color and I just needed to change it to 01;35m.  Below is a handy chart I found with all the ubuntu color codes.

VSQru

Sources:

https://askubuntu.com/questions/123268/changing-colors-for-user-host-directory-information-in-terminal-command-prompt
https://askubuntu.com/questions/27314/script-to-display-all-terminal-colors

Published inOtherScripting

Be First to Comment

Leave a Reply

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