Skip to content

Instantly share code, notes, and snippets.

@vdugnist
Created April 13, 2018 10:37
Show Gist options
  • Save vdugnist/5d3afb586039510867bec4b2d90f7cff to your computer and use it in GitHub Desktop.
Save vdugnist/5d3afb586039510867bec4b2d90f7cff to your computer and use it in GitHub Desktop.
#!/bin/bash
function exclude_odd_folders_and_format {
egrep -v "^Pods|^tools" | tr '\n' '\0' | xargs -0 clang-format -i -style=file
}
export -f exclude_odd_folders_and_format
if [ $# -eq 0 ]; then
find . -type f -name *.h -o -name *.m -o -name *.mm | sed "s/^\.\///g" | exclude_odd_folders_and_format
exit 0
elif [ "$1" == "--only-modified" ]; then
git status --porcelain | grep -e "^ \\?[AM]" | sed "s/^...//" | grep -E '(.*\.h|.*\.m|.*\.mm)$' | exclude_odd_folders_and_format
exit 0
fi
echo "Unknown argument"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment