Skip to content

Instantly share code, notes, and snippets.

@Zenuncl
Forked from Leask/flora_prompt.sh
Created March 7, 2013 04:03
Show Gist options
  • Save Zenuncl/5105498 to your computer and use it in GitHub Desktop.
Save Zenuncl/5105498 to your computer and use it in GitHub Desktop.
git_inspect_branch() {
git branch 2> /dev/null | grep ^* | sed 's/^\* \(.*\)$/:\1/g'
}
git_inspect_added() {
[[ $(git status 2> /dev/null | grep 'Untracked files:') != '' ]] && echo '+'
}
git_inspect_modified() {
[[ $(git status 2> /dev/null | grep 'modified:') != '' ]] && echo '*'
}
git_inspect_deleted() {
[[ $(git status 2> /dev/null | grep 'deleted:') != "" ]] && echo "-"
}
git_inspect_stash() {
[[ $(git stash list 2> /dev/null | grep 'stash@') != "" ]] && echo "?"
}
git_inspect_dirty() {
echo "$(git_inspect_added)$(git_inspect_modified)$(git_inspect_deleted)$(git_inspect_stash)"
}
NME="\u"
HST="\h"
DIR="\w"
PMT="\$"
RED="\[\033[31m\]"
GEN="\[\033[32m\]"
YEL="\[\033[33m\]"
OFF="\[\033[m\]"
MOD="\`if [ \$? = 0 ]; then echo 😃; else echo 😓; fi\`" # Mountain Lion only
# MOD="\`if [ \$? = 0 ]; then echo ':)'; else echo ':('; fi\`" # Other OSs
GIT="\`git_inspect_branch\`"
DIF="\`git_inspect_dirty\`"
PMT="\`if [ "$(id -u)" = "0" ]; then echo '#'; else echo '>'; fi\`"
PS1="$MOD $NME@$RED$HST$OFF:$DIR$GEN$GIT$OFF$RED$DIF$OFF$PMT "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment