Last active
August 29, 2015 14:09
-
-
Save arildm/d68aba055084acc17941 to your computer and use it in GitHub Desktop.
Git repo 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
IBlack="\[\033[0;90m\]" # High-intensity Black | |
BYellow="\[\033[1;33m\]" # Bold Yellow | |
Green="\[\033[0;32m\]" # Green | |
IRed="\[\033[0;91m\]" # High-intensity Red | |
Yellow="\[\033[0;33m\]" # Yellow | |
Color_Off="\[\033[0m\]" # Text Reset | |
# Bash prompt for Git repos, based on | |
# http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt but inserts | |
# the branch/dirty marker in the path. | |
export PS1=" | |
$IBlack \t $BYellow"'$( | |
git branch &> /dev/null; | |
if [ $? -eq 0 ]; then | |
echo $(pwd | sed s:$(pwd -P | sed s:^$(git rev-parse --show-toplevel)::)$:: | sed s:$HOME:~:)$( | |
git status | grep "nothing to commit" > /dev/null 2>&1; | |
if [ $? -eq 0 ]; | |
then echo '"'$Green'"'$(__git_ps1 " (%s)"); | |
else echo '"'$Red'"'$(__git_ps1 " {%s}"); | |
fi | |
)'"'$BYellow'"'$( | |
echo $(pwd -P) | sed s:$(git rev-parse --show-toplevel)::g | |
); | |
else | |
echo "\w"; | |
fi | |
)'$Color_Off' $ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment