I often use fzf
to navigate the filesystem, especially the Alt-c key binding.
When invoked, fzf
generates a list from the current working directory.
Is it possible to make fzf
generate a list from a specified directory?
I have tried fzf <dir>
, but it results in an error (unknown option). Also, I can't find any options like -C <dir>
for specifying the start directory.
Assuming you're using bash or similar, this is built into the default completion options which get installed with fzf: https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh
tldr; enter start file or directory, append
**
and hitTab
. So if you'd entercd /foo/**
then tab opens fzf with /foo as start directory.edit at the time of writing the commands for which this works are hardcoded in fzf's bash helpers, which is why this works for
cat
andcd
but not fortac
ornano
. This is the complete list:To add other commands use this in e.g. your .bashrc, after the place where fzf gets sourced (something like
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
):Alternatively: open an issue to ask for the commands you want to be added to fzf by default, things like tac and nano are super common anyway.