How can I display the absolute path in bash prompt?
Just replace \w
with \$PWD
:
PS1="\[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`:\$PWD\n\$ "
Anyway if you mind a little tip, I'd write something like:
PS1='\[`[ $? = 0 ] && X=2 || X=1; tput setaf $X`\]\h\[`tput sgr0`\]:$PWD\n\$ '
Put in your home .bashrc
PS1='\u@\h:\w\$ '