Skip to content

Instantly share code, notes, and snippets.

@ohnoitsyou
Last active April 25, 2017 05:44
Show Gist options
  • Select an option

  • Save ohnoitsyou/fa924e0f2d71bf77dfb119c11d80b594 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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