Skip to content

Instantly share code, notes, and snippets.

@jaumef
Last active May 17, 2021 07:37
Show Gist options
  • Save jaumef/3b154a572fce2b54c2aee00843bc6834 to your computer and use it in GitHub Desktop.
Save jaumef/3b154a572fce2b54c2aee00843bc6834 to your computer and use it in GitHub Desktop.
Check status of repo and reformat + check typing
#!/bin/bash
# Link/copy this file to your bin folder so you can run this easily
#
# ln -s $PWD/status.sh ~/.local/bin/status
pyfiles=$(git status -s | grep -vE '^ ?[DR] ' | awk {'print $2'} | grep '.py')
if [[ $pyfiles ]]
then
# Do you need to activate the virtualenv before
# running black/mypy. Do it here!
# It will deactivate when it finishes,
# so you can have your 'check' virtualenv
#
# source ~/.venv/myenv/bin/activate
source ~/env/requestmachine/bin/activate
nix run -c black -l 100 $pyfiles
nix run -c mypy $pyfiles
fi
git status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment