zsh - show if git branch have unpushed commits

Actually Im using a slightly modified version of the oh my zsh theme blinks. It show a SSH statement just for optical difference to my local terminal. Also it show the branch and a little star if there are uncommitted changes in the branch.

Is it possible to show that there are unpushed commitments? Maybe also with a little indicator.

# https://github.com/blinks zsh theme

function _prompt_char() {
  if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
    echo "%{%F{blue}%}±%{%f%k%b%}"
  else
    echo ' '
  fi
}

case ${SOLARIZED_THEME:-dark} in
    light) bkg=white;;
    *)     bkg=black;;
esac

ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{%f%k%b%K{${bkg}}%B%F{green}%}]"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{%F{red}%}*%{%f%k%b%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""

PROMPT='%{%f%k%b%}

%{%K{black}%B%F{green}%}%n%{%B%F{blue}%}@%{%B%F{cyan}%}%m%{%B%F{green}%} %{%B%F{red}%}!!SSH!! %{%b%F{yellow}%K{black}%}%~%{%B%F{green}%}$(git_prompt_info)%E%{%f%k%b%}
%{%K{black}%}$(_prompt_char)%{%K{black}%} %#%{%f%k%b%} '

RPROMPT='!%{%B%F{cyan}%}%!%{%f%k%b%}'

thanks in advance denym

Answers


You should use vcs_info module come with zsh.

There is a very detail tutorial shows you how to do it: http://arjanvandergaag.nl/blog/customize-zsh-prompt-with-vcs-info.html

Normally you only need to have ${vcs_info_msg_0_} in your $PROMPT variable after you properly load the vcs_info module, but you can customized the prompt format if you don't like the default one.

BTW, vcs_info, as the name has suggested, also support other VCSs, e.g. svn, hg, cvs, etc.


Just set ZSH_THEME="mortalscumbag" in your ~/.zshrc... It supports the "unpushed" state...

1 file changed, 1 insertion(+), 1 deletion(-)

(ssh) mdesales@pppdc9prd08i ‹ master ↑ › : ~/.oh-my-zsh

The "up arrow" shows that there are unpushed commits...

853102c dosdok
(END)

Need Your Help

Nagios SMS notification error on nagios.log

linux curl notifications sms nagios

[1439979541] HOST NOTIFICATION: nagiosadmin;hplj2605dn;DOWN;notify-host-by-email;CRITICAL - Host Unreachable (192.168.1.30)

Java to C object passing

java android struct jni ioctl

I have C code that call a kernel module and I want to pass a struct to it. This seems doable ex -

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.