18 lines
386 B
Bash
18 lines
386 B
Bash
#!/bin/bash
|
|
# Source this and then run `cds`
|
|
# cd search: cd to a directory, given part of its name
|
|
|
|
# Requires: fd, fzf
|
|
# Usage: cds "Search Term"
|
|
|
|
cds() {
|
|
DIR="$(fd -t d | fzf -1 -q "$1" --layout=reverse --info=inline --height=10%)"
|
|
if [ $? -eq 0 ]; then
|
|
if [ -f "$DIR" ]; then
|
|
cd "$(dirname "$DIR")" && pwd
|
|
else
|
|
cd "$DIR" && pwd
|
|
fi
|
|
fi
|
|
}
|
|
|