Skip to content

Instantly share code, notes, and snippets.

@purcell
Created April 13, 2011 11:38
Show Gist options
  • Save purcell/917389 to your computer and use it in GitHub Desktop.
Save purcell/917389 to your computer and use it in GitHub Desktop.
zsh prompt with git branch
##############################################################################
## Zsh prompt
##############################################################################
# See http://kriener.org/articles/2009/06/04/zsh-prompt-magic
# and http://briancarper.net/blog/570/git-info-in-your-zsh-prompt for more
#autoload -Uz vcs_info
#zstyle ':vcs_info:*:prompt:*' check-for-changes false
cur_git_branch() {
git branch --no-color 2>/dev/null|awk '/^\* (.*)/ {b=$2} END {if (b) {print "[" b "]"}}'
}
setopt PROMPT_SUBST
case $TERM in
xterm*|rxvt*|screen|Apple_Terminal)
PROMPT=$(echo '%{\e]0;%n@%m: %~\a\e[%(?.32.31)m%}%# %{\e[m%}')
#RPROMPT=$(echo '${vcs_info_msg_0_} %{\e[32m%}%3~ %{\e[m%}%U%T%u')
RPROMPT=$(echo '$(cur_git_branch) %{\e[32m%}%3~ %{\e[m%}%U%T%u')
#precmd () {
# vcs_info 'prompt'
#}
# Echo current process name in the xterm title bar
preexec () {
set_proxies
print -Pn "\e]0;$1\a"
}
;;
*)
PROMPT="[%n@%m] %# "
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment