Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Using an fzf command like

command! FzfHere :execute 'cd' "'".term('fd -t d "" .  | fzf 2> /dev/tty')."'"
nmap รท :FzfHere<CR>

There's a drawback that a cancelled fzf select will run the cd with no arguments, moving us back to home folder. What is a good way to approach this?

Can it be done with :if somehow? Or does it require functions?

If all else fails, here's a workaround I came up with:

command! FzfHere :execute 'cd' "'".term('fd -t d "" .  | fzf 2> /dev/tty | xargs dot-if-empty')."'"



if [ $# -eq 0 ]; then
  echo "."
  echo $@

1 Answer

0 votes
selected by
Best answer

I see you have found issue #309 on GitHub with the following command:

command! fzf : let $FZF_RES = term('fzf 2>&0')
            \| if $FZF_RES != ''
            \|     goto $FZF_RES
            \| endif

It doesn't work as expected or you asked the question before seeing it?


That exact one didn't work for me, as it turns out because of 2>&0 bit, so I've abandoned that answer somewhere along the road and forgot it exists. Changing it to 2>/dev/tty works! Thank you.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.

Support Ukraine