2021-12-26 16:21:50 -08:00
|
|
|
#!/bin/bash
|
2022-01-02 17:46:16 -08:00
|
|
|
# Source this and then run `cdf`
|
2021-12-26 16:21:50 -08:00
|
|
|
|
|
|
|
# cd find (interactive): cd to the containing dir of a file, or inside a folder, given part of its name
|
|
|
|
# Basically, an interactive version of what's above
|
|
|
|
# can take an `fd` command
|
|
|
|
# requires that `fzy` is installed
|
2022-01-01 18:24:20 -08:00
|
|
|
cdf() {
|
|
|
|
DIR="$(fd $@ | fzy)"
|
|
|
|
if [ -f "$DIR" ];then
|
|
|
|
cd "$(dirname "$DIR")" && pwd
|
|
|
|
else
|
|
|
|
cd "$DIR" && pwd
|
|
|
|
fi
|
|
|
|
}
|