A flexible way to process the result of customized search with fzf #4140
xuhdev
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The Turning into a Different Process section in README
makes a lot of arguments on why a binding such as
enter:become(vim {})
isbeneficial. These benefits are totally valid and useful in many cases. However,
in most cases, I found the following trick is more flexible and powerful than
adding the desired program to
enter:become
, at least in zsh.Let's say we would like to let
fzf
search for a file in a certain way and letan editor to open it.
FZF_CTRL_T_COMMAND
andFZF_CTRL_T_OPTS
with the desired values, then callfzf-file-widget
.vim
,emacs
, orless
.zle -N function-name
.widget.
For example, this instruction shows how to integrate
rg
andfzf
, and use Vim to open the desired searchresult. The code snippet can be rewritten to:
Now the command is no longer limited to be usable by Vim. I can use it in any
command, such as using an editor:
$ $EDITOR [Ctrl-X Shift-P]
or a different command:
$ git log [Ctrl-X Shift-P]
or multiple times:
Hope this helps!
Beta Was this translation helpful? Give feedback.
All reactions