Last active
August 29, 2015 14:16
-
-
Save jonathanbardo/bb62ca1de747155054dd to your computer and use it in GitHub Desktop.
GIT PS1
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
#!/usr/bin/env bash | |
function BEFORE_PS1 { | |
printf "\e[32m[\e[0m$(whoami)\e[32m]@[\e[0mlocal\e[32m][\e[0m${PWD/#$HOME/~}\e[32m]$(gitPS1)\e[0m" | |
} |
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
#!/usr/bin/env bash | |
#Color the bash PS1 | |
function gitPS1 { | |
gitBranch=$(git branch 2>/dev/null | grep '*' | sed 's/* \(.*\)/\1/') | |
if [ "x$gitBranch" == "x" ]; then | |
echo "" | |
else | |
gitStatus=$(echo `git status` | grep 'nothing to commit' > /dev/null 2>&1) | |
if [ $? -eq 0 ]; then | |
printf "\e[32m[\e[32m$gitBranch\e[32m]\e[0m" | |
else | |
gitStatus=$(echo `git status` | grep "ntracked" > /dev/null 2>&1) | |
if [ $? -eq 0 ]; then | |
printf "\e[32m[\e[31m$gitBranch\e[32m]\e[0m" | |
else | |
printf "\e[32m[\e[33m$gitBranch\e[32m]\e[0m" | |
fi | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment