Skip to content

Instantly share code, notes, and snippets.

@chrispruitt
Created January 12, 2021 19:37
Show Gist options
  • Save chrispruitt/5dde5711e595ad386a3c0f098766dc6e to your computer and use it in GitHub Desktop.
Save chrispruitt/5dde5711e595ad386a3c0f098766dc6e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This file is to be run at the root of a git repo.
# It simply symlinks any .sh files in a .githooks/ directory to the .git/hooks directory,
# effectively installing your versioned git hooks.
# create .git/hooks directory if not exists
(
cd .git || exit 1
mkdir -p hooks
)
for hook in .githooks/*.sh
do
name=${hook/hooks/\/hooks}
name=${name/\.sh/}
echo "linking ${hook} -> ${name}"
ln -s ${hook} ${name}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment