Skip to content

Instantly share code, notes, and snippets.

@danthegoodman
Last active November 9, 2016 22:19
Show Gist options
  • Save danthegoodman/9b5f0210be62552fd8b470534ca47867 to your computer and use it in GitHub Desktop.
Save danthegoodman/9b5f0210be62552fd8b470534ca47867 to your computer and use it in GitHub Desktop.
git-cd
# git change directory
gcd() {
local gitdir result
gitdir=$(git rev-parse --show-toplevel 2>/dev/null)
[[ -z "$gitdir" ]] && echo "[not a git directory]" && return 1
result=$(gfind "$gitdir" -type d -not -path '*/\.*' -printf '/%P\n' | fzf --reverse --no-sort)
[[ -z "$result" ]] && return 1
cd "${gitdir}${result}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment