aboutsummaryrefslogtreecommitdiffhomepage
path: root/init/functions/prevd.fish
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-02-08 19:20:05 +1000
committerGravatar axel <axel@liljencrantz.se>2006-02-08 19:20:05 +1000
commit73a9c8bcb8d3d8db967fcc5cc9dd5e8db645400f (patch)
tree13862f394dca16b0c9bae427f86fbbecdfc9ac03 /init/functions/prevd.fish
parent47b652c76e240e16875734f7ca251bab97ae6309 (diff)
Autoloaded functions
darcs-hash:20060208092005-ac50b-8e784f79a4e158c8c15b553fad85002dccc7bd03.gz
Diffstat (limited to 'init/functions/prevd.fish')
-rw-r--r--init/functions/prevd.fish51
1 files changed, 51 insertions, 0 deletions
diff --git a/init/functions/prevd.fish b/init/functions/prevd.fish
new file mode 100644
index 00000000..e71fb2e0
--- /dev/null
+++ b/init/functions/prevd.fish
@@ -0,0 +1,51 @@
+
+function prevd -d "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
+ 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
+
+ # Show history if needed
+ if test $show_hist = 1
+ dirh
+ end
+
+ # Set direction for 'cd -'
+ if test $code = 0 ^/dev/null
+ set -g __fish_cd_direction next
+ end
+
+ # All done
+ return $code
+end
+