Skip to content

Instantly share code, notes, and snippets.

@svenmuennich
Created October 10, 2018 22:54
Show Gist options
  • Save svenmuennich/7dbb085a41583962cc15d6d42207bdd0 to your computer and use it in GitHub Desktop.
Save svenmuennich/7dbb085a41583962cc15d6d42207bdd0 to your computer and use it in GitHub Desktop.
Fix whitespace
#!/bin/bash
# Convert tabs to spaces (https://stackoverflow.com/a/11094620/981846)
find . \( -name '*.m' -o -name '*.h' -o -name '*.swift' -o -name '*.pch' \) ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
# Trim trailing whitespace (https://stackoverflow.com/a/10711226/981846)
find . \( -name '*.m' -o -name '*.h' -o -name '*.swift' -o -name '*.pch' \) ! -type d -exec bash -c 'sed "s/[[:space:]]\{1,\}$//" "$0" > /tmp/e && mv /tmp/e "$0"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment