Last active
November 9, 2016 22:19
-
-
Save danthegoodman/9b5f0210be62552fd8b470534ca47867 to your computer and use it in GitHub Desktop.
git-cd
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
# 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