Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown    



TWEAKING THE PROMPT


There is a big chance your command prompt will look like this: [localhost.localdomain:~]$ , or if your computer is on a network or has a name: [localhost.vector:~]$. It's functional, but if you're like me you won't be happy with it.

You can customize the prompt into something short and fancy, like [bruno:~]$ , ( ~ stands for the current directory and will change as the directory you are in changes ) here is how to do it:

First backup the current prompt:

CODE
$ SAVE=$PS1  

If after tweaking you want the old one back:
 
CODE
$ PS1=$SAVE  


These are the codes we will use:

\u = username of current user
\w = current directory
\h = first part of the hostname
\H = the full hostname
\d = the current date
\t = the current time 24hrs format
\T = the current time 12hrs format
@ = @

Now we can edit the ".bashrc" file ( dot bashrc ):

CODE
$ vi /home/bruno/.bashrc

< i > ( insert mode )
Leave the first few lines as they are.
PS1="[\u:\w]$ " ( a space between the $ and " ) ( this will set the prompt like mine above )
< Esc >
< ZZ >
Close the console, open it again and you'll see the prompt has changed !

Some examples:
PS1="[\H:\w]$ " will give the old [localhost.localdomain:~]$
PS1="[\u:\d \t @\w]$ " will give [bruno: Tue Apr 29 19:04:59 @~]$
PS1="[\t \u@\w]$ " will give [19:04:59 bruno@~]$


If all this was way to easy for you and you want something really different, with colors and shapes, have a look Here
More basic info Here

Your 'root' prompt will not be changed, this makes it even more easy to notice the difference between being root and current user !


Bruno


-- Apr 29 2003 ( Revised Dec 13 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown