I can set an environment variable inside the bash prompt like this:
export PS1="[\u@\H/$FOO \W]\$ "
The prompt does not change when I change the environment variable: $FOO
because the $FOO
variable is not interpreted.
I can work around it by doing the following, exporting PS1 again. But I would like to be able to do it on one line:
[user@server ]$ echo $FOO
foo
[user@server ]$ export PS1="[$FOO]$ "
[foo]$ export FOO=bla
[bla]$
Can this be done in one line?