Make dirh, nextd, prevd work on OS X

This commit is contained in:
ridiculousfish 2012-05-04 18:53:38 -07:00
parent 007c5bc9f0
commit fe7fa46d57
3 changed files with 64 additions and 57 deletions

View file

@ -27,7 +27,7 @@ function dirh --description "Print the current directory history (the back- and
set_color normal
# BSD seq 0 outputs '1 0' instead of nothing
if test (count $dirnext) -gt 0
if count $dirnext > /dev/null
for i in (seq (echo (count $dirnext)) -1 1)
echo -n -e $dirnext[$i]$separator
end

View file

@ -12,6 +12,7 @@ function nextd --description "Move forward in the directory history"
# Parse arguments
set -l show_hist 0
set -l times 1
if count $argv > /dev/null
for i in (seq (count $argv))
switch $argv[$i]
case '-l' --l --li --lis --list
@ -30,9 +31,11 @@ function nextd --description "Move forward in the directory history"
continue
end
end
end
# Traverse history
set -l code 1
if count $times > /dev/null
for i in (seq $times)
# Try one step backward
if __fish_move_last dirnext dirprev;
@ -43,6 +46,7 @@ function nextd --description "Move forward in the directory history"
break
end
end
end
# Show history if needed
if test $show_hist = 1

View file

@ -12,6 +12,7 @@ function prevd --description "Move back in the directory history"
# Parse arguments
set -l show_hist 0
set -l times 1
if count $argv > /dev/null
for i in (seq (count $argv))
switch $argv[$i]
case '-l' --l --li --lis --list
@ -30,9 +31,11 @@ function prevd --description "Move back in the directory history"
continue
end
end
end
# Traverse history
set -l code 1
if count $times > /dev/null
for i in (seq $times)
# Try one step backward
if __fish_move_last dirprev dirnext;
@ -43,6 +46,7 @@ function prevd --description "Move back in the directory history"
break
end
end
end
# Show history if needed
if test $show_hist = 1
@ -57,4 +61,3 @@ function prevd --description "Move back in the directory history"
# All done
return $code
end