I find it helpful to be able to see what branch you have checked out when inside a git repo. Just make the following additions to your .bashrc (or any other file that gets sourced on shell creation).
function parse_git_remote_origin {
git config --get remote.origin.url | sed -Ee "s/^(https:\/\/|git@|ssh:\/\/git@)?([^:\/@]+)[\/:].*(\.git)?$/\2/"
}
# If there are uncommitted changes, append an asterisk to the end of the prompt
function parse_git_dirty {
git diff --no-ext-diff --quiet --exit-code &> /dev/null || echo "*"
}
# Parse out the branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/($(parse_git_remote_origin):\1$(parse_git_dirty))/"
}
# Now edit your command prompt setup, and add the $(parse_git_branch) function
PS1=$(parse_git_branch)$
PS1='\[\033[01;32m\]\u@\h:\[\033[01;36m\]\w\[\033[00m\]\n$(parse_git_branch)\$ '
Looks like:
mbaxa@revan:~/git/mops/Proc
(mortech-stash.zillowgroup.net:master)$