Skip to content

Instantly share code, notes, and snippets.

@mspreij
Last active February 15, 2018 09:57
Show Gist options
  • Save mspreij/ee30ec3e2f5d251439293189246c761c to your computer and use it in GitHub Desktop.
Save mspreij/ee30ec3e2f5d251439293189246c761c to your computer and use it in GitHub Desktop.
# prompt
export PS1="[\u@\h:\w]\[\e[1;32m\]\$(current_git_repository)\[\033[0m\]\$ "
# function used in prompt
function current_git_repository {
local branch=`git branch 2>/dev/null | grep ^\* | cut -b3-`;
local star='';
if [ "$branch" != '' ]; then
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && star='*' || star='';
echo "[$branch$star]"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment