Skip to content

Instantly share code, notes, and snippets.

@harshildarji
Created April 20, 2026 19:20
Show Gist options
  • Select an option

  • Save harshildarji/915393567db1625bb9b375f68be1be1f to your computer and use it in GitHub Desktop.

Select an option

Save harshildarji/915393567db1625bb9b375f68be1be1f to your computer and use it in GitHub Desktop.
Zsh function to autoflake + isort + black Python files, respecting .gitignore boundaries across nested git repos.
# Format Python files respecting .gitignore boundaries
# Requires: autoflake, isort, black
clean() {
if git rev-parse --git-dir >/dev/null 2>&1; then
git ls-files -z --cached --others --exclude-standard '*.py' | xargs -0 autoflake --in-place --remove-unused-variables
else
autoflake -r --in-place --remove-unused-variables .
fi
isort --profile black --skip-gitignore .
black .
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment