Skip to content

Instantly share code, notes, and snippets.

@jpignata
Last active April 13, 2020 08:20
Show Gist options
  • Save jpignata/b13cf23e29e7b21da25c33d0b842464e to your computer and use it in GitHub Desktop.
Save jpignata/b13cf23e29e7b21da25c33d0b842464e to your computer and use it in GitHub Desktop.
Install git-secrets on all repos in home directory
#!/usr/bin/env bash
# Install git-secrets template for new and cloned repos
if [ ! -d "$HOME/.git-templates/git-secrets" ]
then
echo "Installing git-secret globally"
git secrets --register-aws --global
git secrets --install $HOME/.git-templates/git-secrets
git config --global init.templateDir $HOME/.git-templates/git-secrets
fi
# Find and install hook on all existing repos in home directory
for dir in $(find $HOME -type d -name '.git' 2>/dev/null);
do
echo "Installing git-secret to $(dirname $dir)"
cd $dir && \
git secrets --install --force 1>/dev/null && \
git secrets --register-aws
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment