-
-
Save kevinawoo/10787387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # git functions | |
| __git_branch_info() { | |
| git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \ | |
| while read local remote | |
| do | |
| [ -z "$remote" ] && continue | |
| git rev-list --left-right ${local}...${remote} -- 2>/dev/null >/tmp/git_upstream_status_delta || continue | |
| LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta) | |
| RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta) | |
| echo -n "$local..$remote," | |
| [ $LEFT_AHEAD != 0 ] && echo -n "[ahead $LEFT_AHEAD]" | |
| [ $RIGHT_AHEAD != 0 ] && echo -n "[behind $RIGHT_AHEAD]" | |
| echo | |
| done | |
| } | |
| output=$(__git_branch_info | column -t -s '..') | |
| output=${output//[" "] /".."} | |
| output=${output//[". "] /".."} | |
| echo "$output" | column -t -s ',' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| statuses = "!f() { __git_alias_statuses; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment