[PLUG] Directory path in the bash prompt?

Jason Dagit dagit at engr.orst.edu
Wed Jul 17 19:08:53 UTC 2002


On Wed, 17 Jul 2002, Matt Alexander wrote:

>
> On Wed, 17 Jul 2002, Matt Alexander wrote:
>
> > Here's a nice prompt that I use in my ~/.bashrc
> >
> > COLOR1="\[\033[1;35m\]"
> > COLOR2="\[\033[1;36m\]"
> > COLOR3="\[\033[1;32m\]"
> > COLOR4="\[\033[0m\]"
> > PS1="[$COLOR2\u$COLOR4@$COLOR1\h $COLOR3\w$COLOR4]\\$ "

This would be a nice simple prompt, but I can't resist adding two more
features.

PS1="[\@][$COLOR2\u$COLOR4@$COLOR1\h $COLOR3\w$COLOR4]\n\$ "

The \@ will put the time in the prompt (only updates when you hit enter,
but still nice), and \n at the end will put the cursor on a newline so
that it is always in the same colomn on the screen.

There is of course a howto for the bash prompt.  I would recommend it,
because there are quite a few color choices.

And if you want to test a prompt there are to ways to do that.  One is to:
$ export PS1="your new prompt "
or you can edit your ~/.bashrc or whatever file the prompt is in and then
type:
$ source ~/.bashrc

(But don't type the $, that just means do it at a prompt...)

http://www.linuxselfhelp.com/HOWTO/Bash-Prompt-HOWTO/

HTH
Jason





More information about the PLUG mailing list