308b2314f846fba1c0e6e4a64efc95feaa304a59

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

Message

fix(dirhistory): fix ALT+Left/Right key bindings for iTerm2 (#9940)

Diff

 1diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
 2index 0ee8c6e6a6283bdd67048ca4ce08f4578157a293..cbac84600283fe79df5f731cbeefdd87d783da22 100644
 3--- a/plugins/dirhistory/dirhistory.plugin.zsh
 4+++ b/plugins/dirhistory/dirhistory.plugin.zsh
 5@@ -124,10 +124,14 @@ zle -N dirhistory_zle_dirhistory_back
 6 # xterm in normal mode
 7 bindkey "\e[3D" dirhistory_zle_dirhistory_back
 8 bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
 9-# Mac teminal (alt+left/right)
10-if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
11+# Terminal.app
12+if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
13   bindkey "^[b" dirhistory_zle_dirhistory_back
14 fi
15+# iTerm2
16+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
17+  bindkey "^[^[[D" dirhistory_zle_dirhistory_back
18+fi
19 # Putty:
20 bindkey "\e\e[D" dirhistory_zle_dirhistory_back
21 # GNU screen:
22@@ -136,9 +140,14 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
23 zle -N dirhistory_zle_dirhistory_future
24 bindkey "\e[3C" dirhistory_zle_dirhistory_future
25 bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
26-if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
27+# Terminal.app
28+if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
29   bindkey "^[f" dirhistory_zle_dirhistory_future
30 fi
31+# iTerm2
32+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
33+  bindkey "^[^[[C" dirhistory_zle_dirhistory_future
34+fi
35 bindkey "\e\e[C" dirhistory_zle_dirhistory_future
36 bindkey "\eO3C" dirhistory_zle_dirhistory_future
37