Skip to content

Instantly share code, notes, and snippets.

@bdurand
Last active January 9, 2020 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdurand/00ed9e833c800fd3ce3f5a131b32abd8 to your computer and use it in GitHub Desktop.
Save bdurand/00ed9e833c800fd3ce3f5a131b32abd8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Strip trailing whitespace from modified code files in git.
set -o errexit
# set -o xtrace
git diff --cached --name-only --diff-filter=ACM | egrep -e '\.(rb|js|css|scss|erb|html)$' | xargs sed -i '' -E 's/[[:space:]]+$//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment