5fe22fcbc6364aaacce373d71fa7d6b6f2d11a33

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Clean up and fix +1/-0 syntax to work as expected

This change follows this proposed behaviour:

 Ctrl+Shift+Left:  move to last visited directory
 Ctrl+Shift+Right: move to next visited directory

an alternative behaviour would be:

 Ctrl+Shift+Left:  move directory to the left in `dirs` output
 Ctrl+Shift+Right: move directory to the right in `dirs` output

It also introduces `setopt nopushdminus` as a way to standardise
pushd syntax. It's value wasn't clear before, which has been the
cause of so many pull requests regarding this plugin not working
in some environments.

Diff

 1diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh
 2index c6b6ba78576f5d1d51b79ee642f9a8b7210057dd..2064af46a5819d9ddcbe6d23e0b871a69f6d311d 100644
 3--- a/plugins/dircycle/dircycle.plugin.zsh
 4+++ b/plugins/dircycle/dircycle.plugin.zsh
 5@@ -1,10 +1,27 @@
 6-##
 7-# dircycle plugin: enables cycling through the directory
 8-# stack using Ctrl+Shift+Left/Right
 9+# enables cycling through the directory stack using
10+# Ctrl+Shift+Left/Right
11+#
12+# left/right direction follows the order in which directories
13+# were visited, like left/right arrows do in a browser
14 
15-eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
16+# NO_PUSHD_MINUS syntax:
17+#  pushd +N: start counting from left of `dirs' output
18+#  pushd -N: start counting from right of `dirs' output
19+setopt nopushdminus
20+
21+insert-cycledleft () {
22+	zle push-line
23+	LBUFFER='pushd -q +1'
24+	zle accept-line
25+}
26 zle -N insert-cycledleft
27-bindkey "\e[1;6D" insert-cycledleft
28-eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
29+
30+insert-cycledright () {
31+	zle push-line
32+	LBUFFER='pushd -q -0'
33+	zle accept-line
34+}
35 zle -N insert-cycledright
36+
37+bindkey "\e[1;6D" insert-cycledleft
38 bindkey "\e[1;6C" insert-cycledright