2006-02-08 17:20:05 +08:00
|
|
|
|
2010-09-18 10:18:26 +08:00
|
|
|
function dirh --description "Print the current directory history (the back- and fwd- lists)"
|
2006-11-18 00:24:38 +08:00
|
|
|
|
|
|
|
if count $argv >/dev/null
|
|
|
|
switch $argv[1]
|
|
|
|
case -h --h --he --hel --help
|
|
|
|
__fish_print_help dirh
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2006-02-08 17:20:05 +08:00
|
|
|
# Avoid set comment
|
|
|
|
set -l current (command pwd)
|
|
|
|
set -l separator " "
|
2006-12-13 01:11:18 +08:00
|
|
|
set -l line_len (math (count $dirprev) + (echo $dirprev $current $dirnext | wc -m) )
|
2006-02-08 17:20:05 +08:00
|
|
|
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_color $fish_color_history_current
|
|
|
|
echo -n -e $current$separator
|
|
|
|
set_color normal
|
2012-05-05 09:37:24 +08:00
|
|
|
|
|
|
|
# BSD seq 0 outputs '1 0' instead of nothing
|
2012-05-05 09:53:38 +08:00
|
|
|
if count $dirnext > /dev/null
|
2012-05-05 09:37:24 +08:00
|
|
|
for i in (seq (echo (count $dirnext)) -1 1)
|
|
|
|
echo -n -e $dirnext[$i]$separator
|
|
|
|
end
|
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
|
|
|
echo
|
|
|
|
end
|
|
|
|
|