Closed eggbean closed 1 year ago
\
s because the whole string is quoted.fzf --bind=ctrl-o:execute-silent(nvim {})+abort
won't work in your command-line. You're passing two arguments, --bind=ctrl-o:execute-silent(nvim
and {})+abort
, which fzf cannot understand.execute
instead of execute-silent
because you want to use nvim interactively.history | fzf
--ansi
to the default. See https://github.com/junegunn/fzf#performanceexport FZF_DEFAULT_OPTS="
--ansi
--reverse
--bind=ctrl-a:toggle-all
--bind=ctrl-u:preview-page-up
--bind='ctrl-o:execute(nvim {})+abort'
--bind=alt-bs:clear-query
--color spinner:#8BE9FD
--color header:#8BE9FD
"
Thank you for replying, but using your line above now nvim does execute, it seems to immediately exit, and fzf doesn't abort, so needs to be cancelled. It would have been a nice way to open files in the text editor, but it doesn't seem to be possible.
Also, my variable doesn't work at all without the trailing backslash line endings. I am using tmux with fzf appearing in a popup window, if that makes any difference.
export FZF_DEFAULT_OPTS=" \
--ansi \
--reverse \
--bind=ctrl-a:toggle-all \
--bind=ctrl-alt-j:preview-down \
--bind=ctrl-alt-k:preview-up \
--bind=ctrl-d:preview-page-down \
--bind=ctrl-u:preview-page-up \
--bind='ctrl-o:execute($EDITOR {})+abort' \
--bind=alt-bs:clear-query \
--bind=ctrl-h:deselect \
--bind=ctrl-l:select \
--color fg:#F8F8F2 \
--color fg+:#F8F8F2 \
--color bg:-1 \
--color bg+:-1 \
--color hl:#50FA7B \
--color hl+:#FFB86C \
--color info:#BD93F9 \
--color prompt:#50FA7B \
--color pointer:#FF79C6 \
--color marker:#FF5555 \
--color spinner:#8BE9FD \
--color header:#8BE9FD \
"
Works for me fine without backslashes. Try changing the command to $EDITOR {} > /dev/tty
.
https://github.com/junegunn/fzf/issues/1360#issuecomment-966054123
Thanks, that works. However, the text editor opens in the tmux popup window instead of in the original pane. I suppose I should have expected this. Cheers.
opens in the tmux popup window
fzf is a filter program that is designed to be used in shell scripts and this is what I would do.
# This should work well
result=$(fzf-tmux -p) && vim "$result"
IMO, relying on execute+abort
instead feels a bit like a hack. And like I mentioned above, fzf isn't just for files so setting up a global binding that opens an entry in the editor is not recommended.
But if you really want, you can do something like tmux new-window $EDITOR {}
.
That works great. I won't use this keybinding when I am not using fzf to show text files, so I think it will be okay.
Thanks for your help.
man fzf
)I have
FZF_DEFAULT_OPTS
set like this, which has always worked fine, but I want to add--bind=ctrl-o:'execute-silent(nvim {})'
, but I do not know how to escape the{}
or whatever that needs to be escaped, as it this doesn't work:The introduction of this new key binding breaks the whole variable.