I want to display the current working directory in my prompt differently if I am in a symlink
than not.
I have this far:
[[ `pwd -P` = `pwd` ]] && echo "\[1;31m\]$(pwd -P)" || echo "\[1;32m\]$(pwd)"
will return the desired output but it will not work as a replacement for \w
in the command prompt.
I tried wrapping it with backticks but that just results in pwd -Ppwd
in the PS1
.
I want to conditionally change the color and the value if it is a symlink
or not which is why I want the if/else type decision.
This is what I ended up with:
I wanted to change the
pwd
value as well as the color when it is asymlink
.If you want this to actually be efficient (and prompts should be fast to render!), then you'll want to cache the physical lookups, and use
$PWD
rather than$(pwd)
for the logical ones.