zsh-vi-mode icon indicating copy to clipboard operation
zsh-vi-mode copied to clipboard

some ctrl-* keybindings only work with insert mode

Open diminutivesloop opened this issue 2 years ago • 12 comments

General information

  • Terminal program: Terminal 2.12.7
  • Operating system: Mac OS 12.6.1
  • ZSH framework: oh-my-zsh
  • ZSH version: 5.8.1
  • ZVM version: 0.9.0

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

Some ctrl-* keybindings only work in insert mode. Specifically I'm using the per-directory-history zsh plugin and I cannot use ctrl-g to switch between global and directory history when in normal mode even though other keyboard commands such as ctrl-c work in both modes. I'm initializing per-directory-history via zvm_after_init and I tried disabling lazy loading via ZVM_LAZY_KEYBINDINGS=false but this didn't fix the issue.

Reproduction steps

N/A

Expected behavior

Any ctrl-* keybindings that are not assigned to this plugin should work as expected in all input modes.

diminutivesloop avatar Nov 10 '22 16:11 diminutivesloop

Big bump for this one please!!!

cohml avatar Jul 21 '23 05:07 cohml

Hi @diminutivesloop

Thanks for your reporting, I want to confirm the bellowing items with you firstly:

  1. Is it this plugin?
  2. Are you sure, without enabling zsh-vi-mode, this plugin can work under vi normal mode?

Thanks & Regards

jeffreytse avatar Jul 21 '23 09:07 jeffreytse

I'm not @diminutivesloop, but I can be another data point.

I use this plugin, which is the same as the one you linked, except that I install it via Oh-My-Zsh.

With per-directory-history enabled, here's what I've observed:

  • When I enable zsh-vi-mode, CTRL-G stops working.
  • When I disable zsh-vi-mode but enable bindkey -v, CTRL-G stops working.
  • When I disable zsh-vi-mode and disable bindkey -v, CTRL-G works.

cohml avatar Jul 21 '23 13:07 cohml

@cohml Have you tried to source the plugin as below?

zvm_after_init() {
  source <your_plugin_location>/per-directory-history.plugin.zsh
}

jeffreytse avatar Jul 21 '23 14:07 jeffreytse

Hey that fixes it for me!

I know your README already covers this a bit. For some reason it just hadn't occurred to me that zvm_after_init could also work with zsh plugins too.

But in retrospect that makes perfect sense. The README even mentioned zsh-autocomplete specifically... I think your bases are all already covered here 😅

Anyway, sorry for the confusion and thanks for the help! I vote to close this issue.

cohml avatar Jul 21 '23 14:07 cohml

@cohml You're welcome, and hope this plugin can accelerate your daily work. And also welcome to star this project for further updates in the future. : )

jeffreytse avatar Jul 21 '23 14:07 jeffreytse

I'm still not @diminutivesloop lol, so I'd wait for him to respond before closing.

But I will star for sure. This project is great and you are a very responsive dev. Thanks again!

cohml avatar Jul 21 '23 14:07 cohml

@cohml You're welcome, welcome to submit your issues whenever you meet. : )

jeffreytse avatar Jul 21 '23 15:07 jeffreytse

Hi @diminutivesloop

Thanks for your reporting, I want to confirm the bellowing items with you firstly:

1. Is it [this plugin](https://github.com/jimhester/per-directory-history)?

2. Are you sure, without enabling zsh-vi-mode, this plugin can work under vi normal mode?

Thanks & Regards

Yes that's the plugin I'm referring to. And I did just test with the regular vi-mode plugin and the issue manifests in that case as well.

diminutivesloop avatar Jul 21 '23 19:07 diminutivesloop

@diminutivesloop Try this. Just add that to your .zshrc, adjusting the path as necessary ofc.

I had the same issue as you, and this solution seems to have fixed it.

cohml avatar Jul 21 '23 19:07 cohml

@diminutivesloop Could you try as @cohml said, and see if your issue could be settled down?

jeffreytse avatar Jul 24 '23 09:07 jeffreytse

@jeffreytse That appears to work. I tried the same thing before with no success, but that may have been before I switched to installing the HEAD version of this plugin to address another issue.

Update: so I was able to fix the keybinding issue by initializing per-directory-history from zvm_after_init() however I noticed that the shortcut wasn't working exactly as expected. Instead of starting in local mode and then switching to global on ctrl+g it would start in global mode and I had to trigger the keyboard shortcut twice to get to local mode. Eventually I was able to fix both issues by including per-directory-history in my ohmyzsh plugins array in addition to sourcing it in zvm_after_init().

diminutivesloop avatar Aug 10 '23 12:08 diminutivesloop