7ab15bee033a1ce6791b05f4636221cba7b9505e

Author
rhuitl <robert@huitl.de>
Committer
GitHub <noreply@github.com>
Date

Message

feat(dirhistory): add ALT+UP/DOWN key bindings for iTerm2 (#8502)

Diff

 1diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
 2index ec1606940c94864f77640b2f8422b3c362754ddb..0ee8c6e6a6283bdd67048ca4ce08f4578157a293 100644
 3--- a/plugins/dirhistory/dirhistory.plugin.zsh
 4+++ b/plugins/dirhistory/dirhistory.plugin.zsh
 5@@ -2,7 +2,7 @@
 6 #   Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories 
 7 #   that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
 8 # 
 9-#   Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented)
10+#   Navigate directory hierarchy using ALT-UP and ALT-DOWN.
11 #   ALT-UP moves to higher hierarchy (cd ..)
12 #   ALT-DOWN moves into the first directory found in alphabetical order
13 #
14@@ -125,7 +125,7 @@ zle -N dirhistory_zle_dirhistory_back
15 bindkey "\e[3D" dirhistory_zle_dirhistory_back
16 bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
17 # Mac teminal (alt+left/right)
18-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
19+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
20   bindkey "^[b" dirhistory_zle_dirhistory_back
21 fi
22 # Putty:
23@@ -136,7 +136,7 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
24 zle -N dirhistory_zle_dirhistory_future
25 bindkey "\e[3C" dirhistory_zle_dirhistory_future
26 bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
27-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
28+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
29   bindkey "^[f" dirhistory_zle_dirhistory_future
30 fi
31 bindkey "\e\e[C" dirhistory_zle_dirhistory_future
32@@ -175,8 +175,9 @@ zle -N dirhistory_zle_dirhistory_up
33 # xterm in normal mode
34 bindkey "\e[3A" dirhistory_zle_dirhistory_up
35 bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
36-# Mac teminal (alt+up)
37-    #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it
38+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
39+  bindkey "^[[A" dirhistory_zle_dirhistory_up
40+fi
41 # Putty:
42 bindkey "\e\e[A" dirhistory_zle_dirhistory_up
43 # GNU screen:
44@@ -185,7 +186,8 @@ bindkey "\eO3A" dirhistory_zle_dirhistory_up
45 zle -N dirhistory_zle_dirhistory_down
46 bindkey "\e[3B" dirhistory_zle_dirhistory_down
47 bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
48-# Mac teminal (alt+down)
49-    #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it
50+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
51+  bindkey "^[[B" dirhistory_zle_dirhistory_down
52+fi
53 bindkey "\e\e[B" dirhistory_zle_dirhistory_down
54 bindkey "\eO3B" dirhistory_zle_dirhistory_down