Created
September 19, 2023 14:25
-
-
Save vsinha/175d9be7ae1ec256ab0d57c55ed0ce80 to your computer and use it in GitHub Desktop.
f - quickly change directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f() { | |
local dirname | |
dirname=$(cat ~/fcd/fcd-dirs.txt | fzf) || return | |
cd "$dirname" | |
} | |
function _f_no_cache() { | |
local paths=( | |
~/my-corporate-dev-dir/ | |
~/dev | |
) | |
local dirname=$(find $paths -name .git -type d -prune | sed -e 's/\.git//' | fzf) || return | |
cd "$dirname" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 * * * * /path/to/fcd-dirs-generate.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
dirfile="$SCRIPT_DIR/fcd-dirs.txt" | |
git_dirs() { | |
dirname=$1 | |
find "$dirname" -name .git -type d -prune | sed -e 's/\.git//' | |
} | |
{ | |
# Call git_dirs on any folders you're interested in | |
git_dirs ~/relativity-space | |
git_dirs ~/dev | |
} > $dirfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment