Skip to content

Instantly share code, notes, and snippets.

@kane-c
Created May 26, 2015 03:45
Show Gist options
  • Save kane-c/9b9b89bdf70818d0296a to your computer and use it in GitHub Desktop.
Save kane-c/9b9b89bdf70818d0296a to your computer and use it in GitHub Desktop.
Search all git repos in a directory
#!/bin/sh
bold=$(tput bold)
normal=$(tput sgr0)
DIR=`pwd`
for project in $(find * -type d -maxdepth 0)
do
cd $project
if [ -d ".git" ]
then
echo "$bold$project$normal"
results=$(git --no-pager grep -EHIin --untracked --color=always "$@" 2> /dev/null)
if [ $? == 0 ]
then
echo $results
else
echo No results
fi
echo
fi
cd $DIR
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment