Server:extras:colours

From Linux How-To Repository

Jump to: navigation, search

Custom Colouring

Editing Bashrc

Your .bashrc file in your home directory already comes with a colour option. It's pretty easy to find, half way done the file. However, if you "su" to root, you'll loose your colouring unless you have also modified root's .bashrc file.

You can change the colouring to create some interesting effects. Here's a red and blue combination:

   PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[01;31m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Or, here's a basic prompt:

   PS1="\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\] "

But this one is the coolest, although I've experienced a weird spacing error I can't fix:

   PS1='\n\[\033[1;34m\]\342\226\210\342\226\210 \u @ \w\n\[\033[0;36m\]\342\226\210\342\226\210 \t $ \[\033[0;39m\]'

Here's another less fiddly option. Add the lines below to the end of the bashrc file. This one gives you brackets.

   PROMPT_HOSTNAME='mylinuxrocks'
   PROMPT_COLOR='1;37m'
   PROMPT_COLOR2='1;31m'

   PS1='\e[${PROMPT_COLOR}[\e[${PROMPT_COLOR2}\u@${PROMPT_HOSTNAME}\e[${PROMPT_COLOR}] $ '

However, my current prompt is this:

   PS1=' \n${debian_chroot:+($debian_chroot)}\[\033[01;47m\]\u@\h\[\033[01;30m\]: \[\033[01;37m\]\w\[\033[00m\]\[\033[01;30m\] ~: \[\033[0;39m\] '

For more info see: http://ubuntuforums.org/showthread.php?t=31247

Here's a graphic from http://www-128.ibm.com/developerworks/library/l-tip-prompt/


Colour Table
Colour Table


Here's another colouring method:

 * [Howto: Add custom color to directory listings]
Personal tools
KARA Logo