aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/prevd.fish
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-02-17 20:13:39 +1000
committerGravatar axel <axel@liljencrantz.se>2006-02-17 20:13:39 +1000
commit343cafef346543282b5b6e825bc8f9dd10028a48 (patch)
tree1bcf221ecb525c7aeadc8325e7b780d3656e544b /share/functions/prevd.fish
parent95a01f3c8f15034433ffce368d8f2d13d925139c (diff)
Redo installation file structure, move lots of things to $PREFIX/share/fish
darcs-hash:20060217101339-ac50b-d93d2c620a4b7f75f05ff461a6edbee001da7613.gz
Diffstat (limited to 'share/functions/prevd.fish')
-rw-r--r--share/functions/prevd.fish51
1 files changed, 51 insertions, 0 deletions
diff --git a/share/functions/prevd.fish b/share/functions/prevd.fish
new file mode 100644
index 00000000..000a5792
--- /dev/null
+++ b/share/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
+