Skip to content

Instantly share code, notes, and snippets.

@scottstanfield
Created June 14, 2011 17:14
Show Gist options
  • Save scottstanfield/1025376 to your computer and use it in GitHub Desktop.
Save scottstanfield/1025376 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
# execute like:
# % git status |& git-prompt.awk
# (Inspiration from http://niczsoft.com/2010/05/my-git-prompt/)
BEGIN { branch = ""; prefix=""; suffix="" }
/# On branch/ { branch = $4; }
/untracked files present/ { prefix = prefix "*"; }
/Changed but not updated/ { prefix = prefix "^"; }
/Changes to be committed/ { prefix = prefix "~"; }
/nothing to commit/ {}
/branch is ahead/ { suffix = suffix "+"}
END { if (branch != "") { print " (" prefix branch suffix ")"} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment