[cmake-developers] zsh user out there ?

Ben Boeckel mathstuf at gmail.com
Tue Jun 22 19:52:18 EDT 2010


Michael Wild <themiwi at gmail.com> wrote:
> 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

I'll throw mine in as well (yes, I spent too much time on this ;) ):

---------- BEGIN ---------------------------------------------------------------

################################################################################
# Color definitions
################################################################################
BLK="%{"$'\033[30m'"%}"
RED="%{"$'\033[31m'"%}"
GRN="%{"$'\033[32m'"%}"
YLW="%{"$'\033[33m'"%}"
BLU="%{"$'\033[34m'"%}"
MAG="%{"$'\033[35m'"%}"
CYA="%{"$'\033[36m'"%}"
WHT="%{"$'\033[37m'"%}"

NOR="%{"$'\033[00m'"%}"
BLD="%{"$'\033[01m'"%}"

###############################################################################
# vcs_info settings
###############################################################################
autoload -Uz vcs_info && vcs_info

# Enable git cvs and svn magic
zstyle ':vcs_info:*' enable git cvs svn darcs hg

_vcs_fmt_action="${BLD}${MAG}[${CYA}%b${NOR}-${BLD}${WHT}%a${MAG}]${NOR}"
_vcs_fmt_branch="${BLD}${MAG}[${CYA}%b${MAG}]${NOR}"
_vcs_fmt_branch_svn="${CYA}%b${RED}:${YLW}%r${NOR}"
_vcs_fmt_type="${BLD}${MAG}(${GRN}%s${MAG})${NOR}"

# CVS formats
zstyle ':vcs_info:cvs:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:cvs:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# Git formats
zstyle ':vcs_info:git:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:git:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# Hg formats
zstyle ':vcs_info:hg:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:hg:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# Git-svn formats
zstyle ':vcs_info:git-svn:*' branchformat ${_vcs_fmt_branch_svn}
zstyle ':vcs_info:git-svn:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:git-svn:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# Darcs formats
zstyle ':vcs_info:darcs:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:darcs:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# SVN-alike formats
zstyle ':vcs_info:svn:*' branchformat ${_vcs_fmt_branch_svn}
zstyle ':vcs_info:svn:*' actionformats \
        ${_vcs_fmt_action} \
        ${_vcs_fmt_type}
zstyle ':vcs_info:svn:*' formats \
        ${_vcs_fmt_branch} \
        ${_vcs_fmt_type}

# <snip>

################################################################################
# Prompt settings
################################################################################
precmd () {
    vcs_info
}

() {
    local -a _rps1

    # <snip over-engineered PS1 setup ;) >

    _rps1=(
        '${vcs_info_msg_1_}'
        "${WHT}-${NOR}"
        '${vcs_info_msg_0_}'
    )

    RPROMPT=${(j::)_rps1}
}

----------  END  ---------------------------------------------------------------

--Ben




More information about the cmake-developers mailing list