Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A personal indentation config for C files, using ‘indent’.
#! /bin/bash
# A personal indentation config for C files, using ‘indent’.
#
# Every project should agree on and share one of these!
#
# Install ‘indent’: apt-get install indent
# See ‘indent(1)’ for the other 100 options to consider.
#
# Backups are funny. Using an explicit file here, since most careful
# use involves running on one file at a time, which affects backup
# scheme.
origfile="${1?Provide a C input file}"
backup="$1.NOINDENT"
cp "$origfile" "$backup"
#--braces-on-if-line
cmd="
indent
--dont-break-procedure-type
--tab-size2
--no-tabs
--indent-level3
--no-space-after-parentheses
--no-space-after-function-call-names
$origfile
"
eval $cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment