Skip to content

Instantly share code, notes, and snippets.

@whatot
Created August 10, 2017 05:23
Show Gist options
  • Save whatot/41203b561fd13ddfde3796893d2ec26f to your computer and use it in GitHub Desktop.
Save whatot/41203b561fd13ddfde3796893d2ec26f to your computer and use it in GitHub Desktop.
use clang-format to format all c/c++ files based on Google style
#!/bin/bash
set -ue
PROJECT_ROOT=$(readlink -m "$(dirname "$(readlink -f "$0")")"/../)
echo "processing ${PROJECT_ROOT} ..."
find "${PROJECT_ROOT}" -type f \
-regextype posix-egrep -regex ".*\.(h|hpp|cpp|cc)$" -print0 | \
xargs -0 clang-format -style="{BasedOnStyle: Google, IndentWidth: 4}" -i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment