Fix prompt_cwd on darwin systems when $PWD is "/private"

When $PWD is "/private", the prompt was printing "rivate". Skip the
"/private" stripping if there's nothing after it.

Prevent "/private" from being stripped anywhere but the beginning of the
PWD.

Fixes #173
This commit is contained in:
Kevin Ballard 2012-06-21 20:32:07 -07:00 committed by ridiculousfish
parent 4d1c0eaa52
commit 529d410bec

View file

@ -2,7 +2,7 @@
if test (uname) = Darwin
function prompt_pwd --description "Print the current working directory, shortend to fit the prompt"
if test "$PWD" != "$HOME"
printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
printf "%s" (echo $PWD|sed -e 's|^/private\(/.\{1,\}\)|\1|' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/\.\{0,1\}[^/]\([^/]*$\)-\1-'
else
echo '~'