Created
April 24, 2013 04:56
-
-
Save mete0r/5449719 to your computer and use it in GitHub Desktop.
stolen from http://codeinthehole.com/writing/a-useful-git-post-checkout-hook-for-python-repos/ save in .git/hooks/post-checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Delete .pyc files and empty directories from root of project | |
| cd ./$(git rev-parse --show-cdup) | |
| # Clean-up | |
| find . -name ".DS_Store" -delete | |
| NUM_PYC_FILES=$( find . -name "*.pyc" | wc -l | tr -d ' ' ) | |
| if [ $NUM_PYC_FILES -gt 0 ]; then | |
| find . -name "*.pyc" -delete | |
| printf "\e[00;31mDeleted $NUM_PYC_FILES .pyc files\e[00m\n" | |
| fi | |
| NUM_EMPTY_DIRS=$( find . -type d -empty | wc -l | tr -d ' ' ) | |
| if [ $NUM_EMPTY_DIRS -gt 0 ]; then | |
| find . -type d -empty -delete | |
| printf "\e[00;31mDeleted $NUM_EMPTY_DIRS empty directories\e[00m\n" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment