[cmake-developers] zsh user out there ?

Michael Wild themiwi at gmail.com
Tue Jun 22 12:16:41 EDT 2010


On 22. Jun, 2010, at 17:35 , Brad King wrote:

> Mathieu Malaterre wrote:
>> Hi there,
>> 
>>  Is anyone using fancy zsh script to show git branch directly on the
>> shell ? If so what do you recommend ?
> 
> Look at the __git_ps1 function in git-completion.bash that comes
> with Git:
> 
> http://git.kernel.org/?p=git/git.git;a=blob;f=contrib/completion/git-completion.bash;h=545bd4b38368e3c2a3958133bbeef6a19e831fff;hb=d599e0484f8ebac8cc50e9557a4c3d246826843d
> 
> It sets up the prompt for bash.  It can probably be adapted for zsh.
> 
> That said, there may be support in zsh proper already, but I'm not
> familiar with it.
> 
> -Brad

Indeed, I use the vcs_info module that is included in stock-zsh. Here my setup:

# set up prompt (with VCS info)
autoload -Uz vcs_info
setopt prompt_subst
zstyle ':vcs_info:*' enable git 
zstyle ':vcs_info:*' actionformats '%F{magenta}[%s:%F{yellow}%b%f|%F{red}%a%F{magenta}]%f '
zstyle ':vcs_info:*' formats       '%F{magenta}[%s:%F{yellow}%b%F{magenta}]%f '
precmd () {
  vcs_info
  if [ "${vcs_info_msg_0_}" = "" ]; then
    dir_status="%f%#"
  elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
    dir_status="%F{red}▶%f"
  elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
    dir_status="%F{yellow}▶%f"
  else
    dir_status="%F{green}▶%f"
  fi  
}
PS1='%F{red}%n%f@%F{blue}%m %3~ ${vcs_info_msg_0_}${dir_status} '


There's also support for svn, svk, bzr and hg (and possibly others). Refer to zshcontrib(1) for more information.

HTH

Michael


More information about the cmake-developers mailing list