dirs: Stringify

Two useless forks plus one per element in $dirstack.
This commit is contained in:
Fabian Homborg 2017-01-05 02:05:18 +01:00
parent a070dffc4e
commit 5ca63c4956

View file

@ -1,6 +1,6 @@
function dirs --description 'Print directory stack' function dirs --description 'Print directory stack'
# process options # process options
if count $argv >/dev/null if set -q argv[1]
switch $argv[1] switch $argv[1]
case -c case -c
# clear directory stack # clear directory stack
@ -10,9 +10,6 @@ function dirs --description 'Print directory stack'
end end
# replace $HOME with ~ # replace $HOME with ~
echo -n (echo (command pwd) | sed -e "s|^$HOME|~|")" " string replace -r '^'"$HOME"'($|/)' '~$1' -- $PWD $dirstack | string join " "
for i in $dirstack
echo -n (echo $i | sed -e "s|^$HOME|~|")" "
end
echo echo
end end