zsh-fzf-history-search
zsh-fzf-history-search copied to clipboard
Plugin appears nonfunctioning
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.
Which zsh plugin manager are you using?
I just installed it manually using the instructions here for Oh-My-Zsh.
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)
Same for me.
Using ZSH and oh-my-zsh.
When clicking ctrl+r nothing happens.
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
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?
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.
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
I just installed oh-my-zsh on my Macbook Pro. I did these steps:
- Install OMZ:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
-
cd ~/.oh-my-zsh/plugins
-
git clone https://github.com/joshskidmore/zsh-fzf-history-search
- Edit ~/.zshrc and appended
zsh-fzf-history-search
to the plugins=() - 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
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 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 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 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?
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
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.