e9bc107ad502083d91c5bcca1415634563c8b5dc

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(dirhistory): define key bindings for vi mode (#10450)

Fixes #10450

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
  2index 8268147f620da16f2654907e4f553c6c8c0c3d7b..7021fc03a34173f93e5155d038538cc25901331a 100644
  3--- a/plugins/dirhistory/dirhistory.plugin.zsh
  4+++ b/plugins/dirhistory/dirhistory.plugin.zsh
  5@@ -121,31 +121,39 @@ function dirhistory_zle_dirhistory_future() {
  6 }
  7 
  8 zle -N dirhistory_zle_dirhistory_back
  9-bindkey "\e[3D" dirhistory_zle_dirhistory_back    # xterm in normal mode
 10-bindkey "\e[1;3D" dirhistory_zle_dirhistory_back  # xterm in normal mode
 11-bindkey "\e\e[D" dirhistory_zle_dirhistory_back   # Putty
 12-bindkey "\eO3D" dirhistory_zle_dirhistory_back    # GNU screen
 13-case "$TERM_PROGRAM" in
 14-iTerm.app) bindkey "^[^[[D" dirhistory_zle_dirhistory_back ;;   # iTerm2
 15-Apple_Terminal) bindkey "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
 16-esac
 17-if (( ${+terminfo[kcub1]} )); then
 18-  bindkey "^[${terminfo[kcub1]}" dirhistory_zle_dirhistory_back  # urxvt
 19-fi
 20-
 21 zle -N dirhistory_zle_dirhistory_future
 22-bindkey "\e[3C" dirhistory_zle_dirhistory_future    # xterm in normal mode
 23-bindkey "\e[1;3C" dirhistory_zle_dirhistory_future  # xterm in normal mode
 24-bindkey "\e\e[C" dirhistory_zle_dirhistory_future   # Putty
 25-bindkey "\eO3C" dirhistory_zle_dirhistory_future    # GNU screen
 26-case "$TERM_PROGRAM" in
 27-iTerm.app) bindkey "^[^[[C" dirhistory_zle_dirhistory_future ;;   # iTerm2
 28-Apple_Terminal) bindkey "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
 29-esac
 30-if (( ${+terminfo[kcuf1]} )); then
 31-  bindkey "^[${terminfo[kcuf1]}" dirhistory_zle_dirhistory_future # urxvt
 32-fi
 33 
 34+for keymap in emacs vicmd viins; do
 35+  # dirhistory_back
 36+  bindkey -M $keymap "\e[3D" dirhistory_zle_dirhistory_back    # xterm in normal mode
 37+  bindkey -M $keymap "\e[1;3D" dirhistory_zle_dirhistory_back  # xterm in normal mode
 38+  bindkey -M $keymap "\e\e[D" dirhistory_zle_dirhistory_back   # Putty
 39+  bindkey -M $keymap "\eO3D" dirhistory_zle_dirhistory_back    # GNU screen
 40+
 41+  case "$TERM_PROGRAM" in
 42+  Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
 43+  iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;;   # iTerm2
 44+  esac
 45+
 46+  if (( ${+terminfo[kcub1]} )); then
 47+    bindkey -M $keymap "^[${terminfo[kcub1]}" dirhistory_zle_dirhistory_back  # urxvt
 48+  fi
 49+
 50+  # dirhistory_future
 51+  bindkey -M $keymap "\e[3C" dirhistory_zle_dirhistory_future    # xterm in normal mode
 52+  bindkey -M $keymap "\e[1;3C" dirhistory_zle_dirhistory_future  # xterm in normal mode
 53+  bindkey -M $keymap "\e\e[C" dirhistory_zle_dirhistory_future   # Putty
 54+  bindkey -M $keymap "\eO3C" dirhistory_zle_dirhistory_future    # GNU screen
 55+
 56+  case "$TERM_PROGRAM" in
 57+  Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
 58+  iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;;   # iTerm2
 59+  esac
 60+
 61+  if (( ${+terminfo[kcuf1]} )); then
 62+    bindkey -M $keymap "^[${terminfo[kcuf1]}" dirhistory_zle_dirhistory_future # urxvt
 63+  fi
 64+done
 65 
 66 #
 67 # HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
 68@@ -176,27 +184,38 @@ function dirhistory_zle_dirhistory_down() {
 69 }
 70 
 71 zle -N dirhistory_zle_dirhistory_up
 72-bindkey "\e[3A" dirhistory_zle_dirhistory_up    # xterm in normal mode
 73-bindkey "\e[1;3A" dirhistory_zle_dirhistory_up  # xterm in normal mode
 74-bindkey "\e\e[A" dirhistory_zle_dirhistory_up   # Putty
 75-bindkey "\eO3A" dirhistory_zle_dirhistory_up    # GNU screen
 76-case "$TERM_PROGRAM" in
 77-iTerm.app) bindkey "^[^[[A" dirhistory_zle_dirhistory_up ;;     # iTerm2
 78-Apple_Terminal) bindkey "^[[A" dirhistory_zle_dirhistory_up ;;  # Terminal.app
 79-esac
 80-if (( ${+terminfo[kcuu1]} )); then
 81-  bindkey "^[${terminfo[kcuu1]}" dirhistory_zle_dirhistory_up # urxvt
 82-fi
 83-
 84 zle -N dirhistory_zle_dirhistory_down
 85-bindkey "\e[3B" dirhistory_zle_dirhistory_down    # xterm in normal mode
 86-bindkey "\e[1;3B" dirhistory_zle_dirhistory_down  # xterm in normal mode
 87-bindkey "\e\e[B" dirhistory_zle_dirhistory_down   # Putty
 88-bindkey "\eO3B" dirhistory_zle_dirhistory_down    # GNU screen
 89-case "$TERM_PROGRAM" in
 90-iTerm.app) bindkey "^[^[[B" dirhistory_zle_dirhistory_down ;;     # iTerm2
 91-Apple_Terminal) bindkey "^[[B" dirhistory_zle_dirhistory_down ;;  # Terminal.app
 92-esac
 93-if (( ${+terminfo[kcud1]} )); then
 94-  bindkey "^[${terminfo[kcud1]}" dirhistory_zle_dirhistory_down # urxvt
 95-fi
 96+
 97+for keymap in emacs vicmd viins; do
 98+  # dirhistory_up
 99+  bindkey -M $keymap "\e[3A" dirhistory_zle_dirhistory_up    # xterm in normal mode
100+  bindkey -M $keymap "\e[1;3A" dirhistory_zle_dirhistory_up  # xterm in normal mode
101+  bindkey -M $keymap "\e\e[A" dirhistory_zle_dirhistory_up   # Putty
102+  bindkey -M $keymap "\eO3A" dirhistory_zle_dirhistory_up    # GNU screen
103+
104+  case "$TERM_PROGRAM" in