-   Linux - General (
-   -   Bash Prompt - display correct $(pwd) (

tschima 07-04-2007 04:07 PM

Bash Prompt - display correct $(pwd)
When I use $(pwd) in my PS1, whatever the current working dir, the prompt always displays /home/username. However, when I use the \w, I always get the ~ tilde indicating the home dir. Is there a way to get the prompt to indicate that the home dir is /home/username, but always update to display the correct cwd in the prompt? Also, the \W (as opposed to the lowercase \w) doesn't give the whole cwd. Thanks.


jschiwal 07-04-2007 05:37 PM

Use single quotes around the prompt so it isn't evaluated before being assigned to PS1

PS1='${PWD}\$ '


PS1='$(PWD)\$ '

tschima 07-05-2007 08:03 PM

Bash Prompt - display correct $(pwd)

Well, I tried '$(pwd)' and '$(pwd)\$' and it does display the correct current dir, but it also displays the single quotes. I am using bash on RH 7.2 (This is a P1/100 box). I suppose that could have an affect.


All times are GMT -5. The time now is 08:19 AM.