Skip to content

Instantly share code, notes, and snippets.

@PMTM
Created January 27, 2015 13:51
Show Gist options
  • Save PMTM/9ed56606b1f748d9a857 to your computer and use it in GitHub Desktop.
Save PMTM/9ed56606b1f748d9a857 to your computer and use it in GitHub Desktop.
GIT state prompt
export PS1=\\u@\\h:$IBlack$Time12h$Color_Off'$(if [[ ${PWD} == _puth_here_git_active_path_* ]]; then \
git branch &>/dev/null;\
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
# @4 - Clean repository - nothing to commit
echo "'$Green'"$(__git_ps1 " (%s)"); \
else \
# @5 - Changes to working tree
echo "'$IRed'"$(__git_ps1 " {%s}"); \
fi) '$BYellow$PathShort$Color_Off'\$ "; \
else \
# @2 - Prompt when not in GIT repo
echo " '$Yellow$PathShort$Color_Off'\$ "; \
fi \
else \
echo " '$Yellow$PathShort$Color_Off'\$ "; \
fi)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment