zsh-vi-mode
zsh-vi-mode copied to clipboard
Arrow key does not do prefix-based history completion
General information
- Terminal program: iTerm.app 3.4.23 (xterm-256color)
- Operating system: macOS 14.3.1 (23D60)
- ZSH framework: oh-my-zsh master (bebd9ea)
- ZSH version: zsh 5.9 (x86_64-apple-darwin23.0)
- ZVM version: zsh-vi-mode 0.11.0 (781e9a5, 2024-02-11 13:41:10 -0800)
- Installed via Homebrew
Basic examination
- [x] I have read through the README page
- [x] I have the latest version of zsh-vi-mode
- [ ] I have tested with another terminal program
Problem description
Without enabling zsh-vi-mode
, if I type curl
and press ⬆️ key on my keyboard, I get the last command executed with curl
prefix (and successive hits to ⬆️ ⬇️ cycles between those only).
However if I enable zsh-vi-mode
, type curl
and hit ⬆️ , I only get the last executed command (doesn't start with curl
). What would be the reason for that?
Reproduction steps
- enable
zsh-vi-mode
- type
curl
- press up arrow key
- prompt now has the last executed command that doesn't start with
curl...
Expected behavior
By default zsh (or maybe something else I installed) ensures only commands with curl
prefix are provided based on up/down arrow keys.
I'm experiencing the exact same behavior on kitty 0.21.2.
I added
function zvm_before_lazy_keybindings() {
bindkey -M vicmd '^[[A' history-search-backward
bindkey -M viins '^[[A' history-search-backward
bindkey -M vicmd '^[[B' history-search-forward
bindkey -M viins '^[[B' history-search-forward
}
in my .zshrc
But it works after the first time I enter the normal mode.
It works fine if I add
zvm_bindkey vicmd '^[[A' history-search-backward
zvm_bindkey viins '^[[A' history-search-backward
zvm_bindkey vicmd '^[[B' history-search-forward
zvm_bindkey viins '^[[B' history-search-forward
in my zsh-vi-mode.zsh
I have this same issue on wezterm, I modified @thdonatello's suggestion and it worked great. I ended up using this in my .zshrc
zvm_bindkey vicmd "${terminfo[kcuu1]}" up-line-or-history
zvm_bindkey viins "${terminfo[kcuu1]}" up-line-or-history
zvm_bindkey vicmd "${terminfo[kcud1]}" down-line-or-history
zvm_bindkey viins "${terminfo[kcud1]}" down-line-or-history
Is it intended that zsh-vi-mode is overriding the default up and down arrow bindings?
I found this and it works for me