You are not logged in.

#1 2006-04-07 17:38:19

Cobra
Member
Registered: 2004-07-30
Posts: 109

Bash $PWD isn't correct [Solved]

This is my PS1 in /etc/profile

export PS1="[u@h]-[${PWD}]-#-$> "

That means my prompt will look like this:

[username@Hostname]-[/current/directory]-1-$>

This is okay initially, however, if I "cd /some/directory", the bash prompt doesn't say /some/directory, but it remains /current/directory (I know, not really the current directory but the initial directory)

How is this possible? I may have upgraded bash lately, so maybe bash is broken? Maybe it has something to do with initscripts? If I "echo ${PWD}", it echoes the correct new directory, but the prompt doesn't get updated.

Offline

#2 2006-04-07 17:50:32

baze
Member
Registered: 2005-10-30
Posts: 393

Re: Bash $PWD isn't correct [Solved]

why don't you use

export PS1="[u@h]-[w]-#-$> "

?
ok, it shows ~ instead of /home/foo, else it's what you want..

Offline

#3 2006-04-07 17:56:47

Cobra
Member
Registered: 2004-07-30
Posts: 109

Re: Bash $PWD isn't correct [Solved]

You're right, that works, although it doesn't solve the problem with ${PWD}... and to be honest, I prefer /home/myusername instead of ~.  :oops:

Offline

#4 2006-04-07 20:14:05

alterkacker
Member
From: Peoples Republic of Boulder
Registered: 2005-01-08
Posts: 52

Re: Bash $PWD isn't correct [Solved]

The problem is that "${PWD}" is being interpreted by the shell at the time you set the prompt. If you quote it like this "${PWD}" then the shell will interpret it at every prompt & you'll get the behavior you want.

Offline

#5 2006-04-08 11:14:38

Cobra
Member
Registered: 2004-07-30
Posts: 109

Re: Bash $PWD isn't correct [Solved]

Thanks, that works. big_smile
It is weird though, because it used to work all the time... (I'm using Arch for over a year now). Maybe something has changed, but it doesn't matter anymore, it works and I'm happy with the result. wink

Offline

Board footer

Powered by FluxBB