From 79784d3e1867aaaef0f8d2c3779b3080ec2e7bb0 Mon Sep 17 00:00:00 2001 From: Nick Pilon Date: Wed, 23 Jan 2008 04:03:40 +1000 Subject: [PATCH] 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 --- share/functions/prompt_pwd.fish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index b13807075..e694db93e 100644 --- a/share/functions/prompt_pwd.fish +++ b/share/functions/prompt_pwd.fish @@ -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