Skip to content

Instantly share code, notes, and snippets.

@zmalltalker
Created September 29, 2016 07:41
Show Gist options
  • Save zmalltalker/9e13f164030c6e04df866b4812f6575f to your computer and use it in GitHub Desktop.
Save zmalltalker/9e13f164030c6e04df866b4812f6575f to your computer and use it in GitHub Desktop.
# Interesting variables:
# - $COLUMNS: how wide are we?
# - $SECONDS: how long have we been running
# %#: root will have #, others will have %
autoload -U colors
setopt prompt_subst
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
parse_git_dirty () {
if [[ -n $(git status -s 2> /dev/null) ]]; then
echo "✗"
else
echo ""
fi
}
PS1="%F{red}%n%F{blue}(%F{red}%22<..<%4~%F{blue})%F{red}%F{blue}%f "
RPROMPT=$'%F{yellow}$(parse_git_dirty) %F{green}$(git_prompt_info)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment