Skip to content

Instantly share code, notes, and snippets.

@MartyLake
Created November 29, 2018 10:38
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 MartyLake/b76796d70bd65f4e601093477571a566 to your computer and use it in GitHub Desktop.
Save MartyLake/b76796d70bd65f4e601093477571a566 to your computer and use it in GitHub Desktop.
Bash alias to format files that changed before commit
#format only files that have a diff
alias gformat="git diff --name-only --ignore-submodules | xargs -I {} sh -c 'export f="{}"; cd \$(git rev-parse --show-toplevel) && [[ -f \$f ]] && echo formatting \$f && clang-format -i --style=file \$f || echo directory \$f'"
#fix osx gitgui bug + format all files + open git gui and gitk (I use these a lot to commit)
alias gh="git config --local --unset gui.geometry && git push& gformat && git gui & gitk &"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment