Monday, June 29, 2009

Understanding Bash (Part 2)

I like to customise my BASH prompt to be a bit more colourful and informative. You can also do it. But before that you must understand some basis syntax. There are more to the options below


Selected Options for Bash Prompt:
\h (Hostname)
\u (Username of the current user)
\w (current working directory, with the top-level directory as ~)
\W (base name of the current working directory, with top-level directory as ~)


How do we get BASH to look like below under CentOS
[root@test ~/scratch/tmp]$
# vim .bashrc
# export PS1='\e[1;33m[\u@\h \w]\$ \e[m'

\e[a;bm \e[m
(marks the start of the character the colour apply to.)
(a;bm is the color code)
(a can have a value of both 0 and 1. 1 will be the lighter colour of the 0)


For Color Codes, see Changing Colour for ls on BASH Blog

No comments: