How to get similar behaviour like the default CTRL+T binding in fzf with a custom search command?
How to get similar behaviour like the default CTRL+T binding in fzf with a custom search command?
This question is (presumably) about bash and readline keybindings and how to customize them.
I would like to create an alias like this:
alias listvids="rg -g '*.{mkv,mp4,ogv}' --files 2> /dev/null | fzf
to list certain video files in the current directory tree and pipe the input to fzf
for fuzzy searching the results, which does work.
fzf
But then I would like the command to act "the same as" the default CTRL-T binding defined in ~/.fzf/shell/keybindings/key-bindings.bash
, meaning it should paste the selected path from the fzf list into the command line when hitting enter.
~/.fzf/shell/keybindings/key-bindings.bash
With the above command, when I hit enter on a path, it just gets echoed at the command line but does not get inserted into the prompt.
I tried something like
alias listvids="rg -g '*.{mkv,mp4,ogv}' --files 2> /dev/null | fzf --bind=ctrl-j:accept'
in the hope that hitting ctrl-j would result in the selection beeing inserted into the prompt, but I guess this is the wrong direction.
Probably the solution is to link the command to a series of readline keybindings, as this is done for the CTRL+T binding in ~/.fzf/shell/keybindings/key-bindings.bash
~/.fzf/shell/keybindings/key-bindings.bash
bind '"C-t": " C-u C-aC-k`__fzf_select__`eC-eC-yC-aC-yeyC-hC-eer C-h"'
where __fzf_select__
is substituted with my own command "somehow"?
__fzf_select__
I guess the solution can be found in the documentation and I tried, but I have not enough understanding of bash syntax and readline bindings but would still like to be able to use fzf in the above way with custom searches and hitting enter on a selection resulting in the selection getting inserted into the prompt.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Comments
Post a Comment