X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=6533d7262fcc4a1ff8bed274261b254bc3f05c27;hb=deeb32aa922bbc8147950eded42e436e5e8c8439;hp=d6c3dd319946794562e3755e528c244318c37e8a;hpb=6f238eb14ee497b4d561ce68a6d09cf227aee6c6;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index d6c3dd3..6533d72 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -1597,7 +1597,16 @@ fi # is433 # set colors for use in prompts (modern zshs allow for the use of %F{red}foo%f # in prompts to get a red "foo" embedded, but it's good to keep these for # backwards compatibility). -if zrcautoload colors && colors 2>/dev/null ; then +if is437; then + BLUE="%F{blue}" + RED="%F{red}" + GREEN="%F{green}" + CYAN="%F{cyan}" + MAGENTA="%F{magenta}" + YELLOW="%F{yellow}" + WHITE="%F{white}" + NO_COLOR="%f" +elif zrcautoload colors && colors 2>/dev/null ; then BLUE="%{${fg[blue]}%}" RED="%{${fg_bold[red]}%}" GREEN="%{${fg[green]}%}" @@ -1680,21 +1689,61 @@ if zrcautoload vcs_info; then fi fi +typeset -A grml_vcs_coloured_formats +typeset -A grml_vcs_plain_formats + +grml_vcs_plain_formats=( + format "(%s%)-[%b] " "zsh: %r" + actionformat "(%s%)-[%b|%a] " "zsh: %r" + rev-branchformat "%b:%r" +) + +grml_vcs_coloured_formats=( + format "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${MAGENTA}]${NO_COLOR} " + actionformat "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${YELLOW}|${RED}%a${MAGENTA}]${NO_COLOR} " + rev-branchformat "%b${RED}:${YELLOW}%r" +) + +typeset GRML_VCS_COLOUR_MODE=xxx + +grml_vcs_info_toggle_colour () { + emulate -L zsh + if [[ $GRML_VCS_COLOUR_MODE == plain ]]; then + grml_vcs_info_set_formats coloured + else + grml_vcs_info_set_formats plain + fi + return 0 +} + +grml_vcs_info_set_formats () { + emulate -L zsh + #setopt localoptions xtrace + local mode=$1 AF F BF + if [[ $mode == coloured ]]; then + AF=${grml_vcs_coloured_formats[actionformat]} + F=${grml_vcs_coloured_formats[format]} + BF=${grml_vcs_coloured_formats[rev-branchformat]} + GRML_VCS_COLOUR_MODE=coloured + else + AF=${grml_vcs_plain_formats[actionformat]} + F=${grml_vcs_plain_formats[format]} + BF=${grml_vcs_plain_formats[rev-branchformat]} + GRML_VCS_COLOUR_MODE=plain + fi + + zstyle ':vcs_info:*' actionformats "$AF" "zsh: %r" + zstyle ':vcs_info:*' formats "$F" "zsh: %r" + zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat "$BF" + return 0 +} + # Change vcs_info formats for the grml prompt. The 2nd format sets up # $vcs_info_msg_1_ to contain "zsh: repo-name" used to set our screen title. -# TODO: The included vcs_info() version still uses $VCS_INFO_message_N_. -# That needs to be the use of $VCS_INFO_message_N_ needs to be changed -# to $vcs_info_msg_N_ as soon as we use the included version. if [[ "$TERM" == dumb ]] ; then - zstyle ':vcs_info:*' actionformats "(%s%)-[%b|%a] " "zsh: %r" - zstyle ':vcs_info:*' formats "(%s%)-[%b] " "zsh: %r" + grml_vcs_info_set_formats plain else - # these are the same, just with a lot of colors: - zstyle ':vcs_info:*' actionformats "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${YELLOW}|${RED}%a${MAGENTA}]${NO_COLOR} " \ - "zsh: %r" - zstyle ':vcs_info:*' formats "${MAGENTA}(${NO_COLOR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${MAGENTA}]${NO_COLOR}%} " \ - "zsh: %r" - zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat "%b${RED}:${YELLOW}%r" + grml_vcs_info_set_formats coloured fi # Now for the fun part: The grml prompt themes in `promptsys' mode of operation