LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need dynamic prompt (https://www.linuxquestions.org/questions/linux-newbie-8/need-dynamic-prompt-785683/)

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;

redhat5::jholp:/home.jholp>

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


Thanks,

John

rweaver 01-29-2010 03:18 PM

Try something along these lines:

Code:

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:

Code:


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.

John

rweaver 02-01-2010 03:47 PM

Glad to be of assistance :)


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