If you have a home directory of e.g. /root and cd to /tmp/root, the path is shown as /tmp~.
The fix is to change
string replace --ignore-case -- ~ \~ $PWD
to something like:
string replace --ignore-case --regex -- (string join "" "^" ~) \~ $PWD
The string join seems to be needed to concatenate the ^ with the expanded ~.
If you have a home directory of e.g.
/rootand cd to/tmp/root, the path is shown as/tmp~.The fix is to change
string replace --ignore-case -- ~ \~ $PWDto something like:
string replace --ignore-case --regex -- (string join "" "^" ~) \~ $PWDThe
string joinseems to be needed to concatenate the^with the expanded~.