Post History
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() { loc...
#5: Post edited
How to automatically change to the first matching directory using fuzzy search and cd?
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: ```bash 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.
#4: Post edited
Fuzzy change directory
- How to automatically change to the first matching directory using fuzzy search and cd?
#3: Post edited
- 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:
- ```bash
- 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 directory to the closest directory.
- 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:
- ```bash
- 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: Post edited
I want the `cd` command to automatically change to the first directory that matches a fuzzy search using `fzf`, without prompting me to select between multiple options.- This is what I've tried:
- ```bash
- 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 directory to the closest directory.
- 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:
- ```bash
- 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 directory to the closest directory.
#1: Initial revision
Fuzzy change directory
I want the `cd` command to automatically change to the first directory that matches a fuzzy search using `fzf`, without prompting me to select between multiple options. This is what I've tried: ```bash 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 directory to the closest directory.