Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow key does not do prefix-based history completion #266

Open
2 of 3 tasks
ahmetb opened this issue Feb 11, 2024 · 4 comments
Open
2 of 3 tasks

Arrow key does not do prefix-based history completion #266

ahmetb opened this issue Feb 11, 2024 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@ahmetb
Copy link

ahmetb commented Feb 11, 2024

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

  • I have read through the README page
  • 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

  1. enable zsh-vi-mode
  2. type curl
  3. press up arrow key
  4. 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.

@munhoshi
Copy link

I'm experiencing the exact same behavior on kitty 0.21.2.

@thdonatello
Copy link

thdonatello commented Feb 19, 2024

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

@Arethusag
Copy link

Arethusag commented Feb 21, 2024

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?

@jeffreytse jeffreytse self-assigned this Feb 21, 2024
@jeffreytse jeffreytse added the good first issue Good for newcomers label Feb 21, 2024
@thdonatello
Copy link

thdonatello commented Feb 21, 2024

I found this and it works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants