Comments on How to automatically change to the first matching directory using fuzzy search and cd?
Post
How to automatically change to the first matching directory using fuzzy search and cd?
+2
−1
I want the cd
command to automatically change to the first directory that matches a fuzzy search, without prompting me to select between multiple options.
This is what I've tried:
cd() {
local dir="$1"
local selected_dir
selected_dir=$(find . -depth 1 -type d 2>/dev/null | fzf +m -q "$dir" --height 40% --reverse --select-1)
builtin cd "$selected_dir"
}
This prompts me to select between different directories but I want to change automatically to the first match.
2 comment threads