2006-02-08 17:20:05 +08:00
|
|
|
|
2007-01-16 09:29:18 +08:00
|
|
|
function nextd --description "Move forward in the directory history"
|
2006-11-18 00:24:38 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
if count $argv >/dev/null
|
|
|
|
switch $argv[1]
|
|
|
|
case -h --h --he --hel --help
|
|
|
|
__fish_print_help nextd
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
set -l show_hist 0
|
|
|
|
set -l times 1
|
|
|
|
if count $argv >/dev/null
|
2012-05-05 09:53:38 +08:00
|
|
|
for i in (seq (count $argv))
|
|
|
|
switch $argv[$i]
|
|
|
|
case '-l' --l --li --lis --list
|
|
|
|
set show_hist 1
|
|
|
|
continue
|
|
|
|
case '-*'
|
|
|
|
printf (_ "%s: Unknown option %s\n" ) nextd $argv[$i]
|
|
|
|
return 1
|
|
|
|
case '*'
|
|
|
|
if test $argv[$i] -ge 0 ^/dev/null
|
|
|
|
set times $argv[$i]
|
|
|
|
else
|
|
|
|
printf (_ "%s: The number of positions to skip must be a non-negative integer\n" ) nextd
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
continue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# Traverse history
|
|
|
|
set -l code 1
|
|
|
|
if count $times >/dev/null
|
2012-05-05 09:53:38 +08:00
|
|
|
for i in (seq $times)
|
|
|
|
# Try one step backward
|
2016-11-28 13:27:22 +08:00
|
|
|
if __fish_move_last dirnext dirprev
|
|
|
|
|
2012-05-05 09:53:38 +08:00
|
|
|
# We consider it a success if we were able to do at least 1 step
|
|
|
|
# (low expectations are the key to happiness ;)
|
|
|
|
set code 0
|
|
|
|
else
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# Show history if needed
|
|
|
|
if test $show_hist = 1
|
|
|
|
dirh
|
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# Set direction for 'cd -'
|
|
|
|
if test $code = 0 ^/dev/null
|
|
|
|
set -g __fish_cd_direction prev
|
|
|
|
end
|
2006-02-08 17:20:05 +08:00
|
|
|
|
2016-11-28 13:27:22 +08:00
|
|
|
# All done
|
|
|
|
return $code
|
2010-09-18 10:18:26 +08:00
|
|
|
end
|