Skip to content

Instantly share code, notes, and snippets.

@drblue
Created November 15, 2022 14:32
Show Gist options
  • Save drblue/76605dead9a76c493dcc718819230120 to your computer and use it in GitHub Desktop.
Save drblue/76605dead9a76c493dcc718819230120 to your computer and use it in GitHub Desktop.
Git-prompt for bash
function git-branch-name {
git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3
}
function git-branch-prompt {
local branch=`git-branch-name`
if [ $branch ]; then printf " [%s]" $branch; fi
}
PS1="\u@\h \[\033[0;36m\]\w\[\033[0m\]\[\033[0;32m\]\$(git-branch-prompt)\[\033[0m\] \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment