From 5ca63c495656745475a5afe3978dae26aafbec47 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 5 Jan 2017 02:05:18 +0100 Subject: [PATCH] dirs: Stringify Two useless forks plus one per element in $dirstack. --- share/functions/dirs.fish | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/share/functions/dirs.fish b/share/functions/dirs.fish index 9f57aba93..7fd5b0494 100644 --- a/share/functions/dirs.fish +++ b/share/functions/dirs.fish @@ -1,6 +1,6 @@ function dirs --description 'Print directory stack' # process options - if count $argv >/dev/null + if set -q argv[1] switch $argv[1] case -c # clear directory stack @@ -10,9 +10,6 @@ function dirs --description 'Print directory stack' end # replace $HOME with ~ - echo -n (echo (command pwd) | sed -e "s|^$HOME|~|")" " - for i in $dirstack - echo -n (echo $i | sed -e "s|^$HOME|~|")" " - end + string replace -r '^'"$HOME"'($|/)' '~$1' -- $PWD $dirstack | string join " " echo end