This patch fixes a problem where prompt_pwd was printing the full path twice under OS X and probably BSDs. (Which, needless to say, made for very long prompts) The problem was that (Free?)BSD sed and GNU sed handle ? differently. For BSD sed, ? is not special unless the -E flag is specified. The {0,1} syntax should work the same way in both.

darcs-hash:20080122180340-5b666-21f1cdb835cbfa458a0f3d7344370837db962388.gz
This commit is contained in:
Nick Pilon 2008-01-23 04:03:40 +10:00
parent c08c313c0a
commit 79784d3e18

View file

@ -2,8 +2,8 @@
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-/\(\.\?[^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/\.\?[^/]\([^/]*$\)-\1-'
printf "%s" (echo $PWD|sed -e 's|/private||' -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/\.\{0,1\}[^/]\([^/]*$\)-\1-'
else
echo '~'
end
@ -15,8 +15,8 @@ else
echo '~'
case '*'
printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\?[^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -n -e 's-.*/\.\?.\([^/]*\)-\1-p'
printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\(\.\{0,1\}[^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -n -e 's-.*/\.\{0,1}.\([^/]*\)-\1-p'
end
end
end