aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-04-14 18:37:19 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-04-16 18:40:16 -0700
commitf034d8ba3a78b544f48bb72f8db06a047481f1d2 (patch)
tree8f3c1581dfb9d905218549ff781a2d31cc38ecdc /share/functions
parent8eb342ad3c686306cf72052badd686d273d577c6 (diff)
number `dirh` output to make prevd/nextd easier
Fixes #2786
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/dirh.fish50
1 files changed, 19 insertions, 31 deletions
diff --git a/share/functions/dirh.fish b/share/functions/dirh.fish
index 44244e8c..942b1ed9 100644
--- a/share/functions/dirh.fish
+++ b/share/functions/dirh.fish
@@ -1,38 +1,26 @@
+function dirh --description "Print the current directory history (the prev and next lists)"
+ if set -q argv[1]
+ switch $argv[1]
+ case -h --h --he --hel --help
+ __fish_print_help dirh
+ return 0
+ end
+ end
-function dirh --description "Print the current directory history (the back- and fwd- lists)"
-
- if count $argv >/dev/null
- switch $argv[1]
- case -h --h --he --hel --help
- __fish_print_help dirh
- return 0
- end
- end
-
- # Avoid set comment
- set -l current (command pwd)
- set -l separator " "
- set -l line_len (math (count $dirprev) + (echo $dirprev $current $dirnext | wc -m) )
- if test $line_len -gt $COLUMNS
- # Print one entry per line if history is long
- set separator "\n"
- end
-
- for i in $dirprev
- echo -n -e $i$separator
- end
+ set -l dirc (count $dirprev)
+ set -l dirprev_rev $dirprev[-1..1]
+ for i in (seq $dirc -1 1)
+ printf '%2d) %s\n' $i $dirprev_rev[$i]
+ end
- set_color $fish_color_history_current
- echo -n -e $current$separator
- set_color normal
+ echo (set_color $fish_color_history_current)' ' $PWD(set_color normal)
- # BSD seq 0 outputs '1 0' instead of nothing
- if count $dirnext > /dev/null
- for i in (seq (echo (count $dirnext)) -1 1)
- echo -n -e $dirnext[$i]$separator
+ set -l dirc (count $dirnext)
+ if test $dirc -gt 0
+ for i in (seq $dirc)
+ printf '%2d) %s\n' $i $dirnext[$i]
end
end
- echo
+ echo
end
-