#!/bin/bash root=$(git rev-parse --show-toplevel) echo "root dir: $root" echo "enabled hooks: " for f in $root/.git/hooks/*; do if [[ ${f: -7} != ".sample" ]]; then echo " $(basename $f)" fi done if [[ -L "$root/.git/hooks/pre-commit" ]]; then echo "pre-commit already linked" elif [[ -f "$root/.git/hooks/pre-commit" ]]; then echo "pre-commit already exists (as regular file)" else echo "linking pre-commit $HOME/.git_hooks/pre-commit" ln -s $HOME/.git_hooks/pre-commit $root/.git/hooks/pre-commit fi