cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.75k stars 176 forks source link

ctrl-r does not work for some zsh environments #323

Closed jingzhaoou closed 1 year ago

jingzhaoou commented 1 year ago

I really like mcfly and installed it on all my Ubuntu boxes, some with Ubuntu 18.04 and some with Ubuntu 20.04. A puzzling thing is that after adding eval "$(mcfly init zsh)" to my .zshrc, some zsh works fine with ctrl-r while some does not. When things do not work, the existing zsh ctrl-r handling is triggered but not mcfly.

I dumped mcfly init zsh output to a file and use eval "$(cat ${HOME}/mcfly.sh)" to set up mcfly. This allows me to debug things further. I found that for all the cases, the following is executed upon startup.

    zle -N mcfly-history-widget
    bindkey '^R' mcfly-history-widget

But I don't know why ctrl-r works only sometimes. I wonder if anyone has some suggestions how I can debug this issue further. Thanks a lot!

mepsteinpear commented 1 year ago

I also had the binding stop working recently in zsh on MacOS Monterey.

I seemed to have acquired this error when ever I start a new terminal now (not sure it is it related):

(eval):30: command not found: shopt
(eval):80: command not found: bind

Any ideas on how to fix the key binding?

Thanks!

jingzhaoou commented 1 year ago

I installed mcfly on my macOS Ventura, which is working fine. For my not-working Ubuntu cases, I don't see any error thrown out. In fact, it does not seem mcfly-history-widget gets triggered at all when I press "Ctrl-R".

jingzhaoou commented 1 year ago

I figured out the root cause to my issue accidentally this morning. Turn out that "Ctrl-R" was overwritten by fzf. What I had earlier is

eval "$(mcfly init zsh)"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

After flipping the order of the above two lines in my ~/.zshr, mcfly works properly on all my Ubuntu machines.

cantino commented 1 year ago

Glad you figured it out @jingzhaoou!

@mepsteinpear, is this a bash vs zsh issue? https://stackoverflow.com/questions/26616003/shopt-command-not-found-in-bashrc-after-shell-updation

mepsteinpear commented 1 year ago

I don't think it is a bash issue this is on macOS Monterey installed via homebrew. My issues started after running brew upgrade I tried reinstalling McFly again or to downgrade it in brew but there is only listing for mcfly in brew.

cantino commented 1 year ago

I'm not sure, sorry.

mepsteinpear commented 1 year ago

@cantino as with all things rebooting seemed to fix it 🤷

thank you for your attention! 🙇