Skip to content

Instantly share code, notes, and snippets.

@vsinha
Created September 19, 2023 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsinha/175d9be7ae1ec256ab0d57c55ed0ce80 to your computer and use it in GitHub Desktop.
Save vsinha/175d9be7ae1ec256ab0d57c55ed0ce80 to your computer and use it in GitHub Desktop.
f - quickly change directories
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"
}
0 * * * * /path/to/fcd-dirs-generate.sh
#!/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