Skip to content

Instantly share code, notes, and snippets.

@s-newman
Created September 30, 2019 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-newman/1223f7ba3dcec4f380e26a3600642537 to your computer and use it in GitHub Desktop.
Save s-newman/1223f7ba3dcec4f380e26a3600642537 to your computer and use it in GitHub Desktop.
A git pre-commit hook script to automatically run the Black formatter for python.
#!/bin/sh
# This relies on a installation of black within a python virtual environment named "black" located at ${HOME}/envs
# Copy me to ${PROJECT_DIR}/.git/hooks/pre-commit
# Then make me executable:
# $ chmod 744 ${PROJECT_DIR}/.git/hooks/pre-commit
${HOME}/envs/black/bin/black .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment