diff options
author | axel <axel@liljencrantz.se> | 2007-09-09 05:17:17 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2007-09-09 05:17:17 +1000 |
commit | c9fe154c0119359c1f09e20cb8b32909b183cad2 (patch) | |
tree | af7807c7acf66e7de1e3dffae902396bb4520199 /share/functions/prompt_pwd.fish | |
parent | 2a3b01a7a0a73d437ce26a45c35774fc5de2cc60 (diff) |
Avoid using test command in prompt, makes it slightly faster
darcs-hash:20070908191717-ac50b-c2d936bff0e7aead0aecad6aa9e024e63b72fc97.gz
Diffstat (limited to 'share/functions/prompt_pwd.fish')
-rw-r--r-- | share/functions/prompt_pwd.fish | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/share/functions/prompt_pwd.fish b/share/functions/prompt_pwd.fish index e971844b..3d9f12d3 100644 --- a/share/functions/prompt_pwd.fish +++ b/share/functions/prompt_pwd.fish @@ -10,11 +10,13 @@ if test (uname) = Darwin end else 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|^$HOME|~|" -e 's-/\([^/]\)\([^/]*\)-/\1-g') - echo $PWD|sed -n -e 's-.*/[^/]\([^/]*$\)-\1-p' - else + switch "$PWD" + case "$HOME" echo '~' + + case '*' + printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\([^/]\)\([^/]*\)-/\1-g') + echo $PWD|sed -n -e 's-.*/.\([^/]*\)-\1-p' end end end |