Created
April 29, 2010 15:45
-
-
Save bobthecow/383792 to your computer and use it in GitHub Desktop.
cd relative to the current Git repo
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 | |
# | |
# cd relative to the current Git repo | |
# | |
# Author: Justin Hileman (http://justinhileman.com) | |
# | |
# Installation: | |
# Add the following function to your `.bashrc` or `.bash_profile`, | |
# or save it somewhere (e.g. `~/.cdg.bash`) and source it in `.bashrc` | |
# | |
# Usage: | |
# cdg [path relative to git dir] | |
cdg () { | |
[[ ! -z $(which git 2> /dev/null) ]] && [[ $(git status 2> /dev/null) ]] && cd "./$(git rev-parse --show-cdup)/$1" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome! Works perfectly, and super short. Thanks for sharing!