0a0a27857e7811b77c35361c759bb566255108db

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #3413 from mcornella/fix-dircycle-plugin

dircycle plugin: clean and fix logic once and for all

Diff

 1diff --git a/plugins/dircycle/dircycle.plugin.zsh b/plugins/dircycle/dircycle.plugin.zsh
 2index c6b6ba78576f5d1d51b79ee642f9a8b7210057dd..1e31105b17e2b2b4d81bca1d8d95aa44e18c6326 100644
 3--- a/plugins/dircycle/dircycle.plugin.zsh
 4+++ b/plugins/dircycle/dircycle.plugin.zsh
 5@@ -1,10 +1,37 @@
 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+
20+insert-cycledleft () {
21+	emulate -L zsh
22+	setopt nopushdminus
23+
24+	builtin pushd -q +1 &>/dev/null || true
25+	zle reset-prompt
26+}
27 zle -N insert-cycledleft
28-bindkey "\e[1;6D" insert-cycledleft
29-eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
30+
31+insert-cycledright () {
32+	emulate -L zsh
33+	setopt nopushdminus
34+
35+	builtin pushd -q -0 &>/dev/null || true
36+	zle reset-prompt
37+}
38 zle -N insert-cycledright
39-bindkey "\e[1;6C" insert-cycledright
40+
41+
42+# add key bindings for iTerm2
43+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
44+	bindkey "^[[1;6D" insert-cycledleft
45+	bindkey "^[[1;6C" insert-cycledright
46+else
47+	bindkey "\e[1;6D" insert-cycledleft
48+	bindkey "\e[1;6C" insert-cycledright
49+fi