Last active
January 29, 2022 22:55
-
-
Save ikwyl6/6ca8c1572614733118bbd60dbcd77404 to your computer and use it in GitHub Desktop.
'git status' alias function that colors the output if 'branch is ahead' or 'branch is behind' upstream repo
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
# created by [email protected] | |
# alias function for 'git status' - colors the 'branch is ahead' or 'branch is behind' | |
# Add to your .bashrc and then do '$ source ~/.bashrc' | |
function gs() { | |
# Do I have any stashes I didn't know about? | |
git stash list | sed -E -e $'s/stash@\{[0-9]+\}/\e[0;31m&\e[0m/' | |
if [[ -z "$1" ]]; then | |
branch="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})" | |
else branch="$1" | |
fi | |
# alias gs - colorize part where local repo is behind or ahead of remote HEAD | |
git -c color.ui=always status | sed -E -e $'s/branch\ is\ ahead|behind/\e[31m&\e[0m/' -e $'s/branch\ is\ up\ to\ date/\e[0;32m&\e[0m/' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment