Skip to content

Instantly share code, notes, and snippets.

@comzeradd
Created October 24, 2013 07:53
Show Gist options
  • Save comzeradd/7132968 to your computer and use it in GitHub Desktop.
Save comzeradd/7132968 to your computer and use it in GitHub Desktop.
delete .pyc and empty folders on checkout
#!/usr/bin/env bash
# Delete .pyc files and empty directories from root of project
cd ./$(git rev-parse --show-cdup)
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 "Deleted $NUM_EMPTY_DIRS empty directories\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment