Created
October 14, 2014 15:58
-
-
Save BrianMehrman/b0698f0c29caf0478bc4 to your computer and use it in GitHub Desktop.
git branch in bash prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------------------------------------------------- | |
# PROMPT | |
# ---------------------------------------------------------------------- | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/" | |
} | |
LBLUE="\[\e[0;36m\]" | |
GREEN="\[\e[0;32m\]" | |
YELLOW="\[\e[0;33m\]" | |
VIOLAT="\[\e[0;94m\]" | |
PS_CLEAR="\[\e[0m\]" | |
export PS1="${YELLOW}[${GREEN}\u${LBLUE}@${VIOLAT}\h${YELLOW}][${LBLUE}\w${YELLOW}]\$(parse_git_branch) ♆${PS_CLEAR} " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to your .bash_profile in your user's root directory.
Then run source ~/.bash_profile to refresh.
When you cd into a directory with git you should see this.
[bmehrman@Mehrman-MBP]~/projects/vmi-ruby ♆