Skip to content

Instantly share code, notes, and snippets.

@taq
Last active December 22, 2015 00:49
Show Gist options
  • Save taq/6392286 to your computer and use it in GitHub Desktop.
Save taq/6392286 to your computer and use it in GitHub Desktop.
# Use it like `export PS1="\h:\w[\$(ahead_behind)]$"`
function ahead_behind {
curr_branch=$(git rev-parse --abbrev-ref HEAD);
curr_remote=$(git config branch.$curr_branch.remote);
curr_merge_branch=$(git config branch.$curr_branch.merge | cut -d / -f 3);
git rev-list --left-right --count $curr_branch...$curr_remote/$curr_merge_branch | tr -s '\t' '|';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment