Skip to content

Instantly share code, notes, and snippets.

@dnutiu
Last active February 11, 2019 10:29
Show Gist options
  • Select an option

  • Save dnutiu/e6498ac2c3bf6d581a22daa6086d68ad to your computer and use it in GitHub Desktop.

Select an option

Save dnutiu/e6498ac2c3bf6d581a22daa6086d68ad to your computer and use it in GitHub Desktop.
Format all python files with black before comiting them.
#!/usr/bin/env bash
files=`git status | grep -e "modified:.*\.py" | sed -E "s/\s*modified:\s*//"`
for FILE in ${files}
do
echo "Running black on" ${FILE}
black ${FILE}
done
# Add modified stagged files back to stagged.
git diff --name-only --cached | xargs -l git add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment