diff options
author | Nick Pilon <npilon@gmail.com> | 2008-01-23 04:03:40 +1000 |
---|---|---|
committer | Nick Pilon <npilon@gmail.com> | 2008-01-23 04:03:40 +1000 |
commit | 79784d3e1867aaaef0f8d2c3779b3080ec2e7bb0 (patch) | |
tree | 6c65335acc70267246df3687a23b306f9b1539b3 /share/functions/prompt_pwd.fish | |
parent | c08c313c0a077249ec49ee5737a3e3d9898a7f50 (diff) |
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
Diffstat (limited to 'share/functions/prompt_pwd.fish')
-rw-r--r-- | share/functions/prompt_pwd.fish | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index b1380707..e694db93 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 |