Last active
April 25, 2017 05:44
-
-
Save ohnoitsyou/fa924e0f2d71bf77dfb119c11d80b594 to your computer and use it in GitHub Desktop.
Quick script to look for directories under git version control and quickly switch to it
This file contains hidden or 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 | |
| if [ -z "$1" ] | |
| then | |
| echo "Please provide a project name" | |
| fi | |
| if [ "-list" == "$1" ] | |
| then | |
| DEBUG=true | |
| else | |
| DEBUG=false | |
| fi | |
| PROJECTDIR=~/projects | |
| for dir in `find $PROJECTDIR -maxdepth 4 -type d -name \.git`; do | |
| dir=`dirname $dir` | |
| if [ "$DEBUG" = true ] | |
| then | |
| echo `basename $dir` | |
| else | |
| if [ "`basename $dir`" == "$1" ] | |
| then | |
| cd $dir | |
| break | |
| fi | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment