Last active
December 19, 2015 22:19
-
-
Save dylanmei/6026331 to your computer and use it in GitHub Desktop.
my git-ps1-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
| # Reset | |
| Color_Off="\[\033[0m\]" | |
| # Regular Colors | |
| Black="\[\033[0;30m\]" | |
| Red="\[\033[0;31m\]" | |
| LightRed="\[\033[1;31m\]" | |
| Green="\[\033[0;32m\]" | |
| LightGreen="\[\033[1;32m\]" | |
| Brown="\[\033[0;33m\]" | |
| Yellow="\[\033[1;33m\]" | |
| Blue="\[\033[0;34m\]" | |
| Purple="\[\033[0;35m\]" | |
| LightPurple="\[\033[1;35m\]" | |
| Cyan="\[\033[0;36m\]" | |
| LightCyan="\[\033[1;36m\]" | |
| White="\[\033[0;37m\]" | |
| export PS1=$Color_Off'$(git branch &>/dev/null;\ | |
| if [ $? -eq 0 ]; then \ | |
| echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \ | |
| if [ "$?" -eq "0" ]; then \ | |
| # Clean repository - nothing to commit | |
| echo "'$Purple'$(__basepath)'$LightPurple'\W'$Green'"$(__git_ps1 " (%s)"); \ | |
| else \ | |
| # Changes to working tree | |
| echo "'$Purple'$(__basepath)'$LightPurple'\W'$Red'"$(__git_ps1 " (%s)"); \ | |
| fi)\n'$LightCyan'> '$Color_Off'"; \ | |
| else \ | |
| # Prompt when not in GIT repo | |
| echo "'$Purple'$(__basepath)'$LightPurple'\W '$LightCyan'\$ '$Color_Off'"; \ | |
| fi)' | |
| __basepath() { | |
| if [ `dirname $PWD` == '/' ] && [ `basename $PWD` == '/' ]; then | |
| echo '' | |
| elif [ `dirname $PWD` == '/' ]; then | |
| echo '/' | |
| else | |
| echo "`dirname $PWD`/" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment