2022-01-01 18:24:20 -08:00
|
|
|
#!/bin/bash
|
2022-01-02 17:46:16 -08:00
|
|
|
# Source this and then run `cds`
|
2022-01-01 18:24:20 -08:00
|
|
|
# cd search: cd to a directory, given part of its name
|
2022-03-31 01:03:49 -07:00
|
|
|
|
2022-04-01 06:24:11 -07:00
|
|
|
# Requires: fd, fzf
|
2022-04-01 11:47:47 -07:00
|
|
|
# Usage: cds "Search Term"
|
2022-01-01 18:24:20 -08:00
|
|
|
|
|
|
|
cds() {
|
2022-04-01 11:47:47 -07:00
|
|
|
DIR="$(fd -t d | fzf -1 -q "$1" --layout=reverse --info=inline --height=10%)"
|
2022-03-31 01:03:49 -07:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
if [ -f "$DIR" ]; then
|
2022-01-01 18:24:20 -08:00
|
|
|
cd "$(dirname "$DIR")" && pwd
|
|
|
|
else
|
|
|
|
cd "$DIR" && pwd
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|