Just add the following function to your .bashrc
or equivalent. Tested on Ubuntu 24.04 with Bash.
d() {
local results count dir
results=$(fd -td -I -- "$1")
count=$(printf '%s\n' "$results" | grep -c .)
if [ "$count" -eq 1 ]; then
cd "$results"
elif [ "$count" -gt 1 ]; then
dir=$(printf '%s\n' "$results" | fzf)
[ -n "$dir" ] && cd "$dir"
fi
}
Updated: