Bash prompt not recognizing variables
Question
I'm customizing my bash prompt (I use iTerm on OS X Lion), and have tried something like:
PS1='\n[\u]-> '
Just for simplicity, but after reloading my ~/.bash_profile
, my prompt now says:
\n[\u]->
and not what I'm expecting to (a new line, followed by my username).
Any ideas?
Solution
How is the shell being invoked? If it's as sh
, or possibly other ways, it won't be interpreted. Try echo $0
OTHER TIPS
Notice the single quotes in your prompt? Bash syntax treats single and double quotes differently. Use double quotes to allow the shell to expand the special chars.
Also, do you have promptvars
set?
Try replacing the single quotes with double quotes, i.e. PS1="\n[\u]-> "
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow