Skip to content

Instantly share code, notes, and snippets.

@zwrawr
Created October 26, 2017 20:11
Show Gist options
  • Save zwrawr/47ccef825ae64e7012986f667936b4cb to your computer and use it in GitHub Desktop.
Save zwrawr/47ccef825ae64e7012986f667936b4cb to your computer and use it in GitHub Desktop.
Simple addition to ~/.bashrc to added the current repo and branch name to the bash prompt
# Add to the bottom of your ~/.bashrc to add the current repo and branch to your promot
# Color and formatting match ubuntu's defaults
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
parse_git_repo() {
if [ $(parse_git_branch) ]; then
eval basename -s .git `git config --get remote.origin.url` | sed -e 's/\(.*\)/ (\1)/'
fi
}
export PS1="\[\033[01;32m\]\u@\h \[\033[34m\]\w\[\033[33m\]\$(parse_git_repo)\$(parse_git_branch)\[\033[00m\] \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment