2016-04-15 09:37:19 +08:00
|
|
|
function dirh --description "Print the current directory history (the prev and next lists)"
|
2017-07-14 02:50:57 +08:00
|
|
|
set -l options 'h/help'
|
|
|
|
argparse -n dirh --max-args=0 $options -- $argv
|
|
|
|
or return
|
|
|
|
|
|
|
|
if set -q _flag_help
|
|
|
|
__fish_print_help dirh
|
|
|
|
return 0
|
2016-04-15 09:37:19 +08:00
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-04-15 09:37:19 +08:00
|
|
|
set -l dirc (count $dirprev)
|
2016-09-12 12:30:39 +08:00
|
|
|
if test $dirc -gt 0
|
|
|
|
set -l dirprev_rev $dirprev[-1..1]
|
|
|
|
# This can't be (seq $dirc -1 1) because of BSD.
|
|
|
|
set -l dirnum (seq 1 $dirc)
|
|
|
|
for i in $dirnum[-1..1]
|
|
|
|
printf '%2d) %s\n' $i $dirprev_rev[$i]
|
|
|
|
end
|
2016-04-15 09:37:19 +08:00
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-04-15 09:37:19 +08:00
|
|
|
echo (set_color $fish_color_history_current)' ' $PWD(set_color normal)
|
2012-11-18 18:23:22 +08:00
|
|
|
|
2016-04-15 09:37:19 +08:00
|
|
|
set -l dirc (count $dirnext)
|
|
|
|
if test $dirc -gt 0
|
2019-01-04 07:00:34 +08:00
|
|
|
set -l dirnext_rev $dirnext[-1..1]
|
2016-04-15 09:37:19 +08:00
|
|
|
for i in (seq $dirc)
|
2019-01-04 07:00:34 +08:00
|
|
|
printf '%2d) %s\n' $i $dirnext_rev[$i]
|
2012-05-05 09:37:24 +08:00
|
|
|
end
|
|
|
|
end
|
2016-04-15 09:37:19 +08:00
|
|
|
echo
|
2006-02-08 17:20:05 +08:00
|
|
|
end
|