Created
June 13, 2013 21:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
autoload -U colors && colors | |
# between the local and remote branches | |
function git_remote_status() { | |
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} | |
if [[ -n ${remote} ]] ; then | |
ahead=$(git rev-list $remote..HEAD 2>/dev/null | wc -l) | |
behind=$(git rev-list HEAD..$remote 2>/dev/null | wc -l) | |
if [ $ahead -eq 0 ] && [ $behind -eq 0 ] | |
then | |
status_str='=' | |
else | |
status_str='' | |
if [ $ahead -gt 0 ] | |
then | |
status_str="$status_str$fg[green]+${ahead// /}$fg[yellow]" | |
fi | |
if [ $ahead -gt 0 ] && [ $behind -gt 0 ] | |
then | |
status_str="$status_str/" | |
fi | |
if [ $behind -gt 0 ] | |
then | |
status_str="$status_str$fg[red]-${behind// /}$fg[yellow]" | |
fi | |
fi | |
echo $status_str | |
fi | |
} | |
function git_remote_prompt() { | |
prompt_info=$(git_prompt_info) || return | |
echo " %{$fg[yellow]%}[$prompt_info$(git_remote_status)]%{$reset_color%}" | |
} | |
PROMPT='%{$fg_bold[green]%}%n@%m %{$fg_bold[blue]%}%(!.%1~.%~)%{$reset_color%}$(git_remote_prompt)$(git_prompt_short_sha) %(!.#.») ' | |
ZSH_THEME_GIT_PROMPT_PREFIX="" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="" | |
ZSH_THEME_GIT_PROMPT_SHA_BEFORE="%{$fg[red]%}[" | |
ZSH_THEME_GIT_PROMPT_SHA_AFTER="]%{$reset_color%}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment