51
15
I currently have my bash PS1
set to something like this:
PS1="\[\`if [[ \$? = "0" ]]; then echo '\e[32m\h\e[0m'; else echo '\e[31m\h\e[0m' ; fi\`:\w\n\$ "
How can I make it show the absolute path instead of the relative one (e.g. /home/dave/dir
instead of ~/dir
)?
1
/home/dave/dir
and~/dir
are both absolute paths, the second uses an abbreviation for your home directory. A relative path is a path that is relative to your current directory (e.g.../dir
) rather than starting at root (/
). – Doug Harris – 2010-10-22T13:38:47.8633p.s. Nice use of color to indicate exit status of previous command. Probably the first use of color in a prompt that I've liked. – Doug Harris – 2010-10-22T13:54:31.643
@Doug Harris: Thanks for the correction. I like this coloring, too. Don't remember where I first saw it (perhaps in some previous SU post?) – David B – 2010-10-22T17:15:16.950
\u@\H[\w]:~\$
makesuser@host[~/path]:~$
– JREAM – 2019-01-03T17:10:21.080