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 function
s?
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')."'"
dot-if-empty:
#!/bin/dash
if [ $# -eq 0 ]; then
echo "."
else
echo $@
fi