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

The up and down key behavior is overwritten, even though it has been overridden in the .zshrc file. #299

Open
kaushiksahu18 opened this issue Nov 2, 2024 · 11 comments

Comments

@kaushiksahu18
Copy link

General information

  • Terminal program: unknown unknown (xterm-kitty)
  • Operating system: Linux (6.11.5-arch1-1 Unsupported grep -P option on Mac OS #1 SMP PREEMPT_DYNAMIC Tue, 22 Oct 2024 18:31:38 +0000 x86_64 GNU/Linux)
  • ZSH framework: starship 1.21.1, zinit v3.13.1-11-gd05a5301 (linux-gnu_x86_64)
  • ZSH version: zsh 5.9 (x86_64-pc-linux-gnu)
  • ZVM version: zsh-vi-mode 0.11.0

Basic examination

  • [ x] I have read through the README page
  • [x ] I have the latest version of zsh-vi-mode
  • [x ] I have tested with another terminal program

Problem description

I would like to utilize the up and down arrow keys for the key bindings listed below, but the current plugin is preventing me from doing so. I am able to access my desired key bindings if I execute the source .zshrc command, however, this action must be performed each time. Alternatively, when I commented out the plugin, the functionality operated as expected. I would appreciate your assistance in resolving this issue.

bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward

Reproduction steps

  1. add this pluin to .zshrc
  2. change bindkey

Expected behavior

...

@rseichter
Copy link

@jeffreytse I have run into the same problem, and it is driving me quite insane. 😉 Using ZVM as an Oh My Zsh plugin, my ~/.zshrc contains this:

# Extend OMZ plugin list
plugins+=(
  zsh-autosuggestions
  zsh-history-substring-search
  zsh-syntax-highlighting
  zsh-vi-mode
)

# ... More setup, including OMZ activation ...

# Last lines in .zshrc
bindkey '^[OA' history-substring-search-up
bindkey '^[OB' history-substring-search-down

Activating zsh-vi-mode like shown above breaks the key bindings used for zsh-history-substring-search. As soon as I disable ZVM, things are working again.

This bug affects me badly, because using the up-arrow to search Zsh history is deeply embedded in my muscle memory.

@kaushiksahu18
Copy link
Author

This bug affects me badly, because using the up-arrow to search Zsh history is deeply embedded in my muscle memory.

you can give a try to Atuin

@rseichter
Copy link

@kaushiksahu18 wrote

you can give a try to Atuin

I'm sorry, but I don't understand your comment. What do you mean?

@miversen33
Copy link

@rseichter they are saying you can use the program Atuin to manage your zsh history.

Which... Ya I mean that's a workaround, but it would be better if we had a way to tell the plugin "Hey don't overwrite these things".

Alternatively I wonder if we were to have vi-mode be the first plugin loaded, would that help?

Basically, let vi-mode be loaded, then all other plugins or settings override what they need to do. Its not ideal but it might work?

@rseichter
Copy link

@miversen33 Thank you for clarifying, Atuin was a complete unknown to me. At first glance, it seems to be a bit of an overkill for my needs, but looking into Atuin in more detail won't hurt.

As for your idea of using plugin load order to our advantage: Does OMZ even have a notion of order/priority when it comes to plugins? I don't recall seeing this mentioned in Oh-My-Zsh documentation yet.

Lastly, while I would not say no to a workaround, the problem is apparently caused by ZVM and should be addressed there. If you look at my .zshrc excerpt above, you see that I set my key bindings as the last step. ZVM somehow interferes with this core Zsh functionality.

@miversen33
Copy link

I don't use oh-my-zsh anymore but I was able to verify that loading zsh-vi-mode before any other plugins does work as expected.

To your question, plugins is just an array, I don't suspect that oh-my-zsh is doing anything special to load the plugins contained in the array. It's almost certainly just looping through from the top. So if you just put zsh-vi-mode in the plugins array first, everything else should be loaded after (or over top) it.

@rseichter
Copy link

I don't use oh-my-zsh anymore but I was able to verify that loading zsh-vi-mode before any other plugins does work as expected.

@miversen33 You were? I tried it myself, and found that placing ZVM in different places in the OMZ plugins array did not solve the problem. History search using the up-arrow key remained broken. Only removing the ZVM plugin restored that functionality.

@miversen33
Copy link

Ahh I should have been more clear. I was able to verify that loading it first works when not using OMZ. IE manually loading plugins. As I stated, I'm not using it anymore, but it's interesting that simply adding the plugin "first" in the plugin array doesn't work.

@rseichter
Copy link

@miversen33 I tried manual plugin loading, and even without using OMZ anymore I still can't get backwards history search to work. Would you perhaps be willing to share your .zshrc file? I would like to understand why it works for you but not for me.

@miversen33
Copy link

@rseichter They likely won't be terribly usable but here is a point in time on my dots that had vi-mode being loaded and then I made changes to the bindkeys after.

The changes I made were to the CTRL-left and CTRL-right keybinds and it worked as expected.

That said, I have since removed vi-mode altogether from my dotfiles as it was just a bit too "obtuse" for my liking.

Since you are using OMZ, are you aware that OMZ includes its own vi-mode you can use?

@rseichter
Copy link

@miversen33 Thanks, your .zshrc looks similar enough to mine that I don't feel like I am making some fundamental mistakes. I am still experimenting. Using OMZ, not using it, loading plugins manually or not, even trying Atuin as @kaushiksahu18 suggested (it is quite a fancy approach, I have to admit). I am uncertain about the best way forward. /me shrugs

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

No branches or pull requests

3 participants