Created
July 24, 2012 15:06
-
-
Save trevmex/3170548 to your computer and use it in GitHub Desktop.
Add git messaging to your bash prompt
This file contains hidden or 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
# | |
# Colors | |
# | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
NORMAL="\[\033[0m\]" | |
# | |
# Prompt Setup | |
# | |
function parse_git_in_rebase { | |
[[ -d .git/rebase-apply ]] && echo " REBASING" | |
} | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
branch=$(git branch 2> /dev/null | grep "*" | sed -e s/^..//g) | |
if [[ -z ${branch} ]]; then | |
return | |
fi | |
echo " ("${branch}$(parse_git_dirty)$(parse_git_in_rebase)")" | |
} | |
export PS1="$RED\u@\h:$GREEN\W$YELLOW\$(parse_git_branch)$NORMAL\$ " # Add git info to the prompt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment