Bash prompt not recognizing variables
Pregunta
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?
Solución
How is the shell being invoked? If it's as sh
, or possibly other ways, it won't be interpreted. Try echo $0
Otros consejos
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]-> "
.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow