[Linux] Bash Prompt Colors

Under your user directory, there’s and file named .bashrc

and it’s default settings is sometimes without colors.

edit this file and find a this line..

PS1=’\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]’

As you can see, the string above contains color-set escape sequences

(start coloring: \[\e[color\], end coloring: \[\e[m\]) and information placeholders:

  • \u – Username. The original prompt also has \h, which prints the host name.
  • \w – Current absolute path. Use \W for current relative path.
  • \$ – The prompt character (eg. # for root, $ for regular users).
  • \[ and \] – These tags should be placed around color codes so bash knows how to properly place the cursor.

 

Color Table:

'\e[0;30m' # Black - Regular
'\e[0;31m' # Red
'\e[0;32m' # Green
'\e[0;33m' # Yellow
'\e[0;34m' # Blue
'\e[0;35m' # Purple
'\e[0;36m' # Cyan
'\e[0;37m' # White

We can change 0 -> 1 to get Bold display

Untitled

And it’ll go like this !!

Dedian-Jessie / Xfce Terminal

Reference:

https://wiki.archlinux.org/index.php/Color_Bash_Prompt

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s