Skip to content

Instantly share code, notes, and snippets.

@beck
Last active September 4, 2015 16:55
Show Gist options
  • Save beck/0119ee3a6bf280a60321 to your computer and use it in GitHub Desktop.
Save beck/0119ee3a6bf280a60321 to your computer and use it in GitHub Desktop.
git util to isort all files with a diff
#!/bin/bash
#
# git isort - isort files with a diff
#
# to use:
# * install isort (this code uses pyenv and has isort installed in 2.7.5)
# * place this file anywhere on PATH, callable via `git isort`
#
isort_cmd=$(pyenv root)/versions/2.7.5/bin/isort
$isort_cmd --version >/dev/null 2>&1
if [ $? != 0 ]
then
echo "isort is broken"
exit
fi
for f in $(git diff head --name-only)
do
echo "isort $f"
$isort_cmd "$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment