atuinsh / atuin

✨ Magical shell history
https://atuin.sh
MIT License
20.38k stars 554 forks source link

^R/incr search keybind being overwritten by zsh-vi-mode #1826

Open schilkp opened 7 months ago

schilkp commented 7 months ago

Hi!

I just spent 40 minutes debugging why the '^R' mapping for incremental search was not being applied. Long story short: I have 'zsh-vi-mode' installed, which "lazy-loads" its keybind after ~/.zshrc has been sourced. This caused the following keybind from the atuin init script to be overwritten:

bindkey -M viins '^r' aution-search-viins

I fixed this by creating a "callback" (I guess?) to have atuin loaded after zsh-vi-mode sets its keybinds:

# If autin is installed, enable it.
if command -v atuin &> /dev/null; then
    # Note: Since zsh-vi-mode lazy-loads keybinds, it will overwrite
    # Some of the keybinds set by atuin. The following creates a 'callback'
    # that loads atuin after zsh-vi-mode has applied all keymaps.
    function my_init() {
        eval "$(atuin init zsh --disable-up-arrow)"
    }
    zvm_after_init_commands+=(my_init)
fi

To be clear: I don't think this is an autin bug per-se, but thought I would open this issue to ask if there was an appropriate place that this could be added to the documentation to avoid future users running into the same issue :)

It seems others have run into this problem: https://stackoverflow.com/questions/77005631/how-can-i-list-all-sourced-files-in-zsh-init-process

Maybe there is also a way to have the default autin init script handle this? Very possible that this would cause conflicts/mess with peoples setups.

arcuru commented 7 months ago

Yep, discussed here as well: #977

I think it's reasonable to add it, it's come up several times and it's a very confusing breakage. The problem is we'd need to figure out how to handle the --disable-up-arrow option.

We already integrate with the zsh-autosuggestions plugin, so handling a fairly popular plugin isn't out of the ordinary.