aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/prevd.fish
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-04 18:53:38 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-05-04 18:53:38 -0700
commitfe7fa46d57a41bbf102fd65b8f63deca5c800c73 (patch)
tree819a0120f86fab2be41f06e3302b2616b63887a0 /share/functions/prevd.fish
parent007c5bc9f0c0d997b9fecb6f7d429a38458de407 (diff)
Make dirh, nextd, prevd work on OS X
Diffstat (limited to 'share/functions/prevd.fish')
-rw-r--r--share/functions/prevd.fish59
1 files changed, 31 insertions, 28 deletions
diff --git a/share/functions/prevd.fish b/share/functions/prevd.fish
index c0361e1f..a1e2d3d3 100644
--- a/share/functions/prevd.fish
+++ b/share/functions/prevd.fish
@@ -12,37 +12,41 @@ function prevd --description "Move back in the directory history"
# Parse arguments
set -l show_hist 0
set -l times 1
- 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" ) prevd $argv[$i]
- return 1
- case '*'
- if test $argv[$i] -ge 0 ^/dev/null
- set times $argv[$i]
- else
- printf (_ "The number of positions to skip must be a non-negative integer\n")
- return 1
- end
- continue
- end
+ if count $argv > /dev/null
+ 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" ) prevd $argv[$i]
+ return 1
+ case '*'
+ if test $argv[$i] -ge 0 ^/dev/null
+ set times $argv[$i]
+ else
+ printf (_ "The number of positions to skip must be a non-negative integer\n")
+ return 1
+ end
+ continue
+ end
+ end
end
# Traverse history
set -l code 1
- for i in (seq $times)
- # Try one step backward
- if __fish_move_last dirprev dirnext;
- # 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
+ if count $times > /dev/null
+ for i in (seq $times)
+ # Try one step backward
+ if __fish_move_last dirprev dirnext;
+ # 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
# 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
-