junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
61.91k stars 2.34k forks source link

[Feature Request] History syntax highlighting #3836

Open l-deniau opened 1 month ago

l-deniau commented 1 month ago

Checklist

Output of fzf --version

0.52.1 (6432f00)

OS

Shell

Problem / Steps to reproduce

I just started to use fzf and i love it. But i've got one problem about the history backsearch with key bidings. I was using https://github.com/zdharma-continuum/history-search-multi-word to have a similar features of fuzzy search with Ctrl-R and it has syntax highlighting wich make it visualy more attractive. So i was wondering if it would be possible to get syntax highlighting like zdharma-continuum/history-search-multi-word for history backsearch with fzf ? Or add an option to disable only the Ctrl-R key biding so i'm able to use fzf with Ctrl-T and Alt-C and zdharma-continuum/history-search-multi-word with Ctrl-R

l-deniau commented 1 month ago

For now i built fzf myself with a modification in key-bindings.zsh like this :

if [[ "${FZF_CTRL_R_COMMAND-x}" != "" ]]; then
zle     -N            fzf-history-widget
bindkey -M emacs '^R' fzf-history-widget
bindkey -M vicmd '^R' fzf-history-widget
bindkey -M viins '^R' fzf-history-widget
fi

and sourcing fzf like this in my zshrc

FZF_CTRL_R_COMMAND= source <(fzf --zsh)
junegunn commented 1 month ago

if it would be possible to get syntax highlighting like zdharma-continuum/history-search-multi-word for history backsearch with fzf ?

I'm not sure. We would have to use bat for syntax highlighting, but our recent change to support multi-line display will probably make it difficult to incorporate that into our script.

Related: https://github.com/sharkdp/bat/issues/2974

Or add an option to disable only the Ctrl-R key biding

Maybe you can load fzf --zsh first, then the other plugin so that the latter overrides CTRL-R binding of fzf?

l-deniau commented 1 month ago

Maybe you can load fzf --zsh first, then the other plugin so that the latter overrides CTRL-R binding of fzf?

Yes, it works. But I don't find it very convenient.

Is there a specific reason that CTRL-R is the only binding where the command can't be overridden, like CTRL-T and ALT-C ?

junegunn commented 1 month ago

Yes, it works. But I don't find it very convenient.

Thanks for the confirmation, so we do have a workaround.

Is there a specific reason that CTRL-R is the only binding where the command can't be overridden

Mainly because no one has asked for it. Opting out of the other keys was a recent addition (see #3678); we didn't include CTRL-R in the patch because there is no FZF_CTRL_R_COMMAND.