Skip to content

Instantly share code, notes, and snippets.

@vetler
Created February 3, 2017 07:26
Show Gist options
  • Save vetler/30e4bce270caa42cad61c9657af2db03 to your computer and use it in GitHub Desktop.
Save vetler/30e4bce270caa42cad61c9657af2db03 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Update all git directories below current directory or specified directory
# Skips directories that contain a file called .ignore
HIGHLIGHT="\e[01;34m"
NORMAL='\e[00m'
function update {
local d="$1"
if [ -d "$d" ]; then
if [ -e "$d/.ignore" ]; then
echo -e "\n${HIGHLIGHT}Ignoring $d${NORMAL}"
else
cd $d > /dev/null
if [ -d ".git" ]; then
echo -e "\n${HIGHLIGHT}Updating `pwd`$NORMAL"
git pull
else
scan *
fi
cd .. > /dev/null
fi
fi
#echo "Exiting update: pwd=`pwd`"
}
function scan {
#echo "`pwd`"
for x in $*; do
update "$x"
done
}
if [ "$1" != "" ]; then cd $1 > /dev/null; fi
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}"
scan *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment