Skip to content

Instantly share code, notes, and snippets.

@paulfryzel
Created October 24, 2012 17:36
Show Gist options
  • Save paulfryzel/3947535 to your computer and use it in GitHub Desktop.
Save paulfryzel/3947535 to your computer and use it in GitHub Desktop.
like gofmt but for c... and using astyle
#!/usr/bin/env bash
# mostly from http://word.bitly.com/post/31921713978/static-analysis
function cfmt {
if [[ $# -ne 1 ]]; then
echo "Usage: cfmt <file>"
else
astyle \
--style=1tbs \
--lineend=linux \
--convert-tabs \
--preserve-date \
--pad-header \
--indent-switches \
--align-pointer=name \
--align-reference=name \
--pad-oper \
--suffix=none \
$1
fi
}
@paulfryzel
Copy link
Author

uses 1TBS style formatting

#include <stdio.h>

int main(int argc, char *argv[])
{
    if (true) {
        printf("Hello World!\n");
    }
    return 0;
}

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