Skip to content

Instantly share code, notes, and snippets.

@purcell purcell/gist:917389
Created Apr 13, 2011

Embed
What would you like to do?
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
You can’t perform that action at this time.