Optimize the fish_prompt function

darcs-hash:20060128102551-ac50b-58580c29fd9537e502bacaad7949433010b5a04b.gz
This commit is contained in:
axel
2006-01-28 20:25:51 +10:00
parent 7f195b2f23
commit 00dea8a082
2 changed files with 20 additions and 8 deletions

View File

@@ -180,17 +180,17 @@ function open -d "Open file in default application"
end
#
# Print the current working directory. If it is too long, it will be
# ellipsised. This function is used by the default prompt command.
# Print the current working directory in a shortened form.This
# function is used by the default prompt command.
#
function prompt_pwd -d "Print the current working directory, shortend to fit the prompt"
set -l wd (pwd)
set -l res (echo $wd|sed -e 's-/\([^/]\)\([^/]*\)-/\1-g')
if test $wd != '~'
set res $res(echo $wd|sed -e 's-.*/[^/]\([^/]*$\)-\1-')
if test "$PWD" != "$HOME"
printf "%s" (echo $PWD|sed -e "s|^$HOME|~|" -e 's-/\([^/]\)\([^/]*\)-/\1-g')
echo $PWD|sed -e 's-.*/[^/]\([^/]*$\)-\1-'
else
echo '~'
end
echo $res
end
#