zsh-fzf-history-search icon indicating copy to clipboard operation
zsh-fzf-history-search copied to clipboard

Plugin appears nonfunctioning

Open cohml opened this issue 1 year ago • 14 comments

MacOS Ventura 13.4

Package versions:

❯ zsh --version
zsh 5.9 (x86_64-apple-darwin22.0)
❯ fzf --version
0.41.1 (brew)

Cloned your master branch today and tested it with the following plugin configurations in .zshrc:

plugins=(
  git
  macos
  z
  zsh-autocomplete
  zsh-autosuggestions
  zsh-fzf-history-search
  zsh-syntax-highlighting
)
plugins=(
  git
  macos
  z
  zsh-autocomplete
  zsh-autosuggestions
  zsh-syntax-highlighting
  zsh-fzf-history-search
)

With the above settings, fzf's CTRL-R output remained in the default format, with the command counter/ID instead of with date and time as described in your README:

 1965  zsh --version
 1966  fzf --version
2/1000 +S -----------------------------------------------------------------------------------------------------------
> ^zsh | ^fzf --version$

Let me know if you're un/able to reproduce.

cohml avatar Jun 27 '23 02:06 cohml

Which zsh plugin manager are you using?

joshskidmore avatar Jun 27 '23 12:06 joshskidmore

I just installed it manually using the instructions here for Oh-My-Zsh.

cohml avatar Jun 27 '23 15:06 cohml

Same issue here. I'm using oh-my-zsh, which I just installed so I could try out zsh-fzf-history-search. Here's the plugins line in my .zshrc:

plugins=(zsh-fzf-history-search)

jordancurve avatar Oct 29 '23 17:10 jordancurve

Same for me.

Using ZSH and oh-my-zsh.

When clicking ctrl+r nothing happens.

dominikduda avatar Nov 02 '23 09:11 dominikduda

Same issue.

If I manually execute"source $ZSH_CUSTOM/plugins/zsh-fzf-history-search/zsh-fzf-history-search.plugin.zsh" after load .zshrc works. But I put this line at the end of .zshrc file and not works

manutepowa avatar Dec 08 '23 05:12 manutepowa

If I manually execute"source $ZSH_CUSTOM/plugins/zsh-fzf-history-search/zsh-fzf-history-search.plugin.zsh" after load .zshrc works.

I can confirm the same. Manually sourcing the file results in timestamps appearing. However, it doesn't seem to respect the nice environment variables that fzf provides, namely FZF_CTRL_R_OPTS. This is a pretty significant bummer.

u/joshskidmore Do you think you will get around to patching the OMZ sourcing failure and overriding of fzf variables?

cohml avatar Dec 08 '23 20:12 cohml

u/joshskidmore Do you think you will get around to patching the OMZ sourcing failure and overriding of fzf variables?

Sorry about the delay. I will take a look at this over the weekend. Because I don't use OMZ, I'm not sure how to resolve this quickly without setting up an environment.

joshskidmore avatar Dec 08 '23 22:12 joshskidmore

In my case I solved it by removing the zsh-vi-mode plugin. Instead I use vi-mode.

I don't understand why but it works

manutepowa avatar Dec 10 '23 07:12 manutepowa

I just installed oh-my-zsh on my Macbook Pro. I did these steps:

  1. Install OMZ: sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  2. cd ~/.oh-my-zsh/plugins
  3. git clone https://github.com/joshskidmore/zsh-fzf-history-search
  4. Edit ~/.zshrc and appended zsh-fzf-history-search to the plugins=()
  5. Opened a new terminal

Using these steps, Ctrl-r works as it does in Zinit - the fzf line format is "[#] [DATE/TIME] [CMD]". Can confirm this was definitely OMZ because my prompt was different than what I use with Zinit.

I can also confirm with this:

➜  plugins git:(master) ✗ bindkey | grep R
"^R" fzf_history_search

joshskidmore avatar Dec 14 '23 00:12 joshskidmore

In thinking about this, one suggestion might be to include zsh-fzf-history-search at the bottom of the plugins=() list. Without knowing everyone's specific scenarios and plugin lists, my assumption is if zsh-fzf-history-search is sourced before another plugin (or if this plugin is included in the plugins=() list before other plugins), other plugins might be hijacking the Ctrl-R key which could be causing a variety of issues.

joshskidmore avatar Dec 14 '23 01:12 joshskidmore

@joshskidmore Thanks for this great plugin! For anyone experiencing issues with this while using zsh-vi-mode, you can fix conflicts with this:

source_if_exists () {
    if test -r "$1"; then
        source "$1"
    fi
}

# see issue: https://github.com/jeffreytse/zsh-vi-mode/issues/4
function after_init() {
    source_if_exists ~/.fzf.zsh
    source_if_exists $ZSH_CUSTOM/plugins/zsh-fzf-history-search/zsh-fzf-history-search.plugin.zsh
}
zvm_after_init_commands+=(after_init)

jonathanmorris180 avatar Jan 12 '24 23:01 jonathanmorris180

@jonathanmorris180 Thanks for the update and solution. As much as I wish this plugin could help "solve" this issue, I think that these keybinding type conflicts probably need to be resolved in individual configs and not the plugin. I'm unsure of what vim-mode behavior is bound to Ctrl-R, but I think it might be a bit presumptuous for this plugin to overwrite its keybinding.

I'm definitely up for suggestions or solutions though. Maybe this is the expected behavior?

joshskidmore avatar Jan 13 '24 15:01 joshskidmore

@joshskidmore No problem. I agree that this would be out of the scope of your plugin. Might suffice to just add a note in the readme about the possibility of conflicts with vim plugins?

jonathanmorris180 avatar Jan 13 '24 21:01 jonathanmorris180

I do not use zsh-vi-mode at all and still have this problem. I had tried to disabled all other plugins except for just zsh-fzf-history-search but still not works. Looks like OMZ has problem with init the shell. My workaround was to add this in ~/.zshrc

source $ZSH_CUSTOM/plugins/zsh-fzf-history-search/zsh-fzf-history-search.plugin.zsh

vietvudanh avatar Feb 29 '24 08:02 vietvudanh

For me it was the order of these lines that caused the issue in my ~/.zshrc:

Fails:

...
[ -f $ZSH/oh-my-zsh.sh ] && source $ZSH/oh-my-zsh.sh
...
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
...

Succeeds:

...
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
...
[ -f $ZSH/oh-my-zsh.sh ] && source $ZSH/oh-my-zsh.sh
...

I hope this helps someone else too.

acohen716 avatar Aug 15 '24 10:08 acohen716