From bf5471dfe99e1dc14a11189f13918226ad5fe5b3 Mon Sep 17 00:00:00 2001 From: Ayaz Badouraly <ayaz.badouraly@via.ecp.fr> Date: Wed, 14 Dec 2016 16:48:18 +0100 Subject: [PATCH] Improving color code in vcs info prompt --- README.md | 8 +++++--- via.zsh-theme | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 52e0b74..a7aeefa 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,11 @@ Info ### VCS caption -| Color | State | -|:-----:|:-----:| -| green | any | +| Color | State | Variable | +|:------:|:--------------------------:|:-----------------------------:| +| red | there are unstaged files | `OHMYVIA_VCS_UNSTAGED_COLOR` | +| yellow | there are staged files | `OHMYVIA_VCS_STAGED_COLOR` | +| green | working directory is clean | `OHMYVIA_VCS_CLEAN_COLOR` | Usage diff --git a/via.zsh-theme b/via.zsh-theme index df7c172..0b84e8c 100644 --- a/via.zsh-theme +++ b/via.zsh-theme @@ -28,6 +28,10 @@ autoload -Uz vcs_info zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' check-for-changes true +local vcs_unstaged_color=${OHMYVIA_VCS_UNSTAGED_COLOR:-"$fg[red]"} +local vcs_staged_color=${OHMYVIA_VCS_STAGED_COLOR:-"$fg[yellow]"} +local vcs_clean_color=${OHMYVIA_VCS_CLEAN_COLOR:-"$fg[green]"} + # In normal formats and actionformats the following replacements are done: # %s : The VCS in use (git, hg, svn, etc.). # %b : Information about the current branch. @@ -39,10 +43,12 @@ zstyle ':vcs_info:*' check-for-changes true # %r : The repository name. If %R is /foo/bar/repoXY, %r is repoXY. # %S : A subdirectory within a repository. If $PWD is /foo/bar/repoXY/beer/tasty, %S is beer/tasty. # %m : A "misc" replacement. It is at the discretion of the backend to decide what this replacement expands to. +zstyle ':vcs_info:*' stagedstr "%{$vcs_staged_color%}" +zstyle ':vcs_info:*' unstagedstr "%{$vcs_unstaged_color%}" zstyle ':vcs_info:*' formats \ - "%{$fg[magenta]%}(%{$fg[white]%}%s%{$fg[magenta]%})%{$fg[yellow]%}-%{$fg[magenta]%}[%{$fg[green]%}%b%{$fg[magenta]%}]%{$reset_color%}" + " %{$fg[magenta]%}(%{$fg[white]%}%s%{$fg[magenta]%})%{$fg[yellow]%}-%{$fg[magenta]%}[%{$vcs_clean_color%}%c%u%b%{$fg[magenta]%}]%{$reset_color%}" zstyle ':vcs_info:*' actionformats \ - "%{$fg[magenta]%}(%{$fg[white]%}%s%{$fg[magenta]%})%{$fg[yellow]%}-%{$fg[magenta]%}[%{$fg[green]%}%b%{$fg[yellow]%}:%{$fg[red]%}%a%{$fg[magenta]%}]%{$reset_color%}" + " %{$fg[magenta]%}(%{$fg[white]%}%s%{$fg[magenta]%})%{$fg[yellow]%}-%{$fg[magenta]%}[%{$vcs_clean_color%}%c%u%b%{$fg[yellow]%}:%{$fg[red]%}%a%{$fg[magenta]%}]%{$reset_color%}" precmd () { vcs_info } RPROMPT='${vcs_info_msg_0_}' -- GitLab