Skip to content

Instantly share code, notes, and snippets.

@exodist
Created March 19, 2014 16:49
Show Gist options
  • Save exodist/9645985 to your computer and use it in GitHub Desktop.
Save exodist/9645985 to your computer and use it in GitHub Desktop.
zsh git stuff
BLACK="%{"$'\033[01;30m'"%}"
GREEN="%{"$'\033[01;32m'"%}"
RED="%{"$'\033[01;31m'"%}"
YELLOW="%{"$'\033[01;33m'"%}"
BLUE="%{"$'\033[01;34m'"%}"
BOLD="%{"$'\033[01;39m'"%}"
NORM="%{"$'\033[00m'"%}"
function gstat() {
branchinfo=`git branch 2>/dev/null`
if [[ $? -eq 0 ]]; then
branch=`echo "${branchinfo}" | grep '^*' | sed 's/* //g'`
echo -n "${BLUE}(${YELLOW}${branch}${NORM}";
stat=`git status -s 2>/dev/null`
echo "${stat}" | grep '^M' 1> /dev/null 2>&1;
staged=$?
echo "${stat}" | grep '^ M' 1> /dev/null 2>&1;
modified=$?
echo "${stat}" | grep '^??' 1> /dev/null 2>&1;
untracked=$?
if [[ $staged -eq 0 || $modified -eq 0 || $untracked -eq 0 ]]; then
echo -n "${NORM}:"
fi
if [[ $staged -eq 0 ]]; then
echo -n "${GREEN}*";
fi
if [[ $modified -eq 0 ]]; then
echo -n "${YELLOW}*";
fi
if [[ $untracked -eq 0 ]]; then
echo -n "${RED}*";
fi
echo "${BLUE})${NORM}"
else
echo ""
fi
}
setopt PROMPT_SUBST
export PS1="${GREEN}%n@%m ${BLUE}$ ${NORM}"
export RPROMPT='$(gstat)${RED}[${BLUE}%~${RED}]${NORM}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment