Here is a use case: I use fzf to search for a list of directories, which then used with the cd command:
cd $(fzf)
However, the fzf command only displays files, not directories. Is there a way to instruct fzf to select only directories?
CodePudding user response:
Per my comment, you can generate a list of directories using find:
cd $(find . -type d -print | fzf)
You can adjust the find command to limit the depth of directories, or to only match directories with specific names, etc.
Generally, you're expected to use fzf as a filter, taking input from some external command.
CodePudding user response:
I suggest to feed only directories to fzf's stdin:
cd "$(printf '%s\n' */ | fzf)"
