Skip to content

Instantly share code, notes, and snippets.

@romellem
Created June 13, 2016 16:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save romellem/2b063de21cd1f90c585060fe803b3dac to your computer and use it in GitHub Desktop.
Save romellem/2b063de21cd1f90c585060fe803b3dac to your computer and use it in GitHub Desktop.
Git hook - Post-commit spell check (using `aspell`)
#!/bin/bash
ASPELL=$(which aspell)
if [ $? -ne 0 ]; then
echo "Aspell not installed - unable to check spelling" >&2
exit
else
WORDS=$($ASPELL --mode=email --add-email-quote='#' list < "$1" | sort -u)
fi
if [ -n "$WORDS" ]; then
printf "\e[1;33m Possible spelling errors found in commit message:\n\e[0m\e[0;31m%s\n\e[0m\e[1;33m Use git commit --amend to change the message.\e[0m\n\n" "$WORDS" >&2
fi
@romellem
Copy link
Author

To use,

  1. Navigate to the root of your git repo.
  2. Navigate to ./git/hooks/
  3. Save the file above as commit-msg
  4. After each commit, you should see misspelled words in your terminal.

Tested on Mac OS 10.10.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment