-   Linux - Newbie (
-   -   Need dynamic prompt (

jholp 01-29-2010 03:11 PM

Need dynamic prompt
Please be patient with me.

I am trying to set a dynamic PROMPT to show me where I am. I have tried the following but it is not working.

PS1=[h::\u:\w]> ;export PS1

my prompt should look like;


But it is not working.

Can yo give me the syntax so my prompt tells me which machine I am
on, who I am on as, and where I am in the directory structure.

This way I do not have to do pwd to see where I am

Once the syntax is correct I place it in .bash_profiel or .profile?

I am using Red Hat 5.2 Server distribution



rweaver 01-29-2010 03:18 PM

Try something along these lines:


export PS1='[\h:\u:\w]\$ '
My custom prompt lives in my .bashrc

Edit: I really would suggest keeping the \$ as it changes based on if you're root or non-root. Helps keep track, but you could put a > in instead if you really feel it has to have a > at the end. To get more or a less exactly what you want would be:


export PS1='[\h::\u:\w]> '

jholp 01-30-2010 05:46 AM

Mr. Weaver,

Thanks, it works perfect. I forgot the single ' is what gives the interpretation of u::, u: etc., etc.


rweaver 02-01-2010 03:47 PM

Glad to be of assistance :)

All times are GMT -5. The time now is 04:07 PM.