Skip to content

Instantly share code, notes, and snippets.

@omehegan
Created April 26, 2017 21:48
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 omehegan/453a34d0dbd6e8099eef9d3398352593 to your computer and use it in GitHub Desktop.
Save omehegan/453a34d0dbd6e8099eef9d3398352593 to your computer and use it in GitHub Desktop.
Warn on unpushed git changes
export PS1="\u@\H \w \$(parse_git_branch)\$ "
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
ref=${ref#refs/heads/}
unpushed=$(git log origin/$ref..$ref 2> /dev/null) || return
if [ "$unpushed" ]; then
warn=' - UNPUSHED!'
fi
echo "("$ref$warn")"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment