Skip to content

Instantly share code, notes, and snippets.

@andrewseidl
Last active August 29, 2015 14:15
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 andrewseidl/18f7cd72f7f1a11835e5 to your computer and use it in GitHub Desktop.
Save andrewseidl/18f7cd72f7f1a11835e5 to your computer and use it in GitHub Desktop.

In the current directory, find all files ending in .(cpp|cu|glsl|h) that are not named *FontData* and are not in a path matching *thirdparty*. Run clang-format on each of these files, using the format specified in .clang-format.

Chrono-Parallel

Linux/GNU find:

find . \( -regex '.*\.\(cpp\|cu\|glsl\|h\)' ! -iname '*FontData*' ! -ipath '*thirdparty*' \) -exec clang-format -i '{}' \;

OSX/BSD find:

find -E . \( -regex '.*\.(cpp|cu|glsl|h)' ! -iname '*FontData*' ! -ipath '*thirdparty*' \) -exec clang-format -i '{}' \;

Chrono

Linux/GNU find:

find . \( -regex '.*\.\(cpp\|cu\|glsl\|h\)' ! -ipath '*/collision/bullet/*'  ! -ipath '*/unit_PYTHON/*'  ! -ipath '*/collision/convexdecomposition/*' ! -ipath '*/collision/gimpact/*' \) -exec clang-format -i '{}' \;

OSX/BSD find:

find -E . \( -regex '.*\.(cpp|cu|glsl|h)' ! -ipath '*/collision/bullet/*'  ! -ipath '*/unit_PYTHON/*'  ! -ipath '*/collision/convexdecomposition/*' ! -ipath '*/collision/gimpact/*' \) -exec clang-format -i '{}' \;

Using clang-format

Installation

Editor support

I have also written a Git hook which will run clang-format on changed files when you commit. This should not be used: you should instead use the command-line tool or the integration with your editor.

original source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment