Skip to content

Instantly share code, notes, and snippets.

@lucaspar
Last active October 4, 2019 20:52
Show Gist options
  • Save lucaspar/6b133ad427fc4eac969d47e2b71345ec to your computer and use it in GitHub Desktop.
Save lucaspar/6b133ad427fc4eac969d47e2b71345ec to your computer and use it in GitHub Desktop.
[ SCR ] Identifies uncommitted changes in git projects
#!/bin/bash
# Detects all git directories and run their status to identify uncommited changes
declare -a dirs=("projects" "work")
# runs git status in directory in argument
gitstatus () {
echo -e "\e[1;35m>>> GIT MONITOR :: " $1 "\e[0m\n"
cd $1
cd ..
git status
printf "\n\n"
return 0
}
export -f gitstatus
# iterate directories array looking for .git directories
echo -e "\e[1;32mChecking for uncommitted changes in these dirs: ${dirs[@]} \e[0m\n"
for i in "${dirs[@]}"
do
find ~/$i -type d -name ".git" -print | xargs -n 1 -I {} bash -c 'gitstatus "$@"' _ {}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment