Skip to content
Snippets Groups Projects
Commit 86c67eed authored by Ayaz Badouraly's avatar Ayaz Badouraly
Browse files

Using zsh built-in support for changing the color

parent b20a23a3
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,23 @@
# Fork from the historical VIA Centrale Réseaux ZSH Theme
local time_format=${OHMYVIA_TIME_FORMAT:-"%D{%H:%M}"}
local clock="%{$fg_bold[cyan]%}$time_format%{$reset_color%}"
local clock="%B%F{cyan}$time_format%f%b"
# Check the UID
if [[ $UID -ne 0 ]];
then
# normal user
local user="%{$fg_bold[red]%}%n%{$reset_color%}"
local eol="%{%(?.$fg_bold[yellow].$fg_bold[red])%}%%%{$reset_color%}"
local user="%B%F{red}%n%f%b"
local eol="%B%(?.%F{yellow}.%F{red})%%%f%b"
else
# root
local user="%{$fg_bold[blue]%}%n%{$reset_color%}"
local eol="%{%(?.$fg_bold[yellow].$fg_bold[red])%}#%{$reset_color%}"
local user="%B%F{blue}%n%f%b"
local eol="%B%(?.%F{yellow}.%F{red})#%f%b"
fi
local user_host="${user}%{$fg_bold[yellow]%}@%{$fg_bold[white]%}%m%{$reset_color%}"
local user_host="${user}%B%F{yellow}@%F{white}%m%f%b"
local current_dir="%{$fg_bold[green]%}%~%{$reset_color%}"
local current_dir="%B%F{green}%~%f%b"
PROMPT='${clock} ${user_host} ${current_dir}${eol} '
......@@ -28,16 +28,16 @@ autoload -Uz vcs_info
zstyle ':vcs_info:*' max-exports 1 # vcs_info only sets vcs_info_msg_0_
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' check-for-changes true # enable %c and %u sequences usage
local vcs_unstaged_color=${OHMYVIA_VCS_UNSTAGED_COLOR:-"$fg[red]"}
local vcs_staged_color=${OHMYVIA_VCS_STAGED_COLOR:-"$fg[yellow]"}
local vcs_stash_color=${OHMYVIA_VCS_STASH_COLOR:-"$fg[blue]"}
local vcs_untracked_color=${OHMYVIA_VCS_UNTRACKED_COLOR:-"$fg[cyan]"}
local vcs_clean_color=${OHMYVIA_VCS_CLEAN_COLOR:-"$fg[green]"}
local vcs_unstaged_color=${OHMYVIA_VCS_UNSTAGED_COLOR:-"%F{red}"}
local vcs_staged_color=${OHMYVIA_VCS_STAGED_COLOR:-"%F{yellow}"}
local vcs_stash_color=${OHMYVIA_VCS_STASH_COLOR:-"%F{blue}"}
local vcs_untracked_color=${OHMYVIA_VCS_UNTRACKED_COLOR:-"%F{cyan}"}
local vcs_clean_color=${OHMYVIA_VCS_CLEAN_COLOR:-"%F{green}"}
zstyle ':vcs_info:*' unstagedstr "%{$vcs_unstaged_color%}"
zstyle ':vcs_info:*' stagedstr "%{$vcs_staged_color%}"
zstyle ':vcs_info:*' unstagedstr $vcs_unstaged_color
zstyle ':vcs_info:*' stagedstr $vcs_staged_color
# Thanks to https://github.com/sunaku/home/
function +vi-git-untracked(){
......@@ -47,14 +47,14 @@ function +vi-git-untracked(){
# If instead you want to show the marker only if there are untracked
# files in $PWD, use:
#[[ -n $(git ls-files --others --exclude-standard) ]] ; then
hook_com[misc]+="%{$vcs_untracked_color%}"
hook_com[misc]+=$vcs_untracked_color
fi
}
# Thanks to http://eseth.org/2010/git-in-zsh.html
function +vi-git-stash() {
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
hook_com[misc]+="%{$vcs_stash_color%}"
hook_com[misc]+=$vcs_stash_color
fi
}
......@@ -71,10 +71,10 @@ zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-stash
# %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.
local vcs_formats_prefix=" %{$fg[magenta]%}(%{$fg[white]%}%s%{$fg[magenta]%})%{$reset_color%}"
local vcs_formats_hyphen="%{$fg[yellow]%}-%{$reset_color%}"
local vcs_formats_normal="%{$fg[magenta]%}[%{$vcs_clean_color%}%m%c%u%b%{$fg[magenta]%}]%{$reset_color%}"
local vcs_formats_action="%{$fg[magenta]%}[%{$vcs_clean_color%}%m%c%u%b%{$fg[yellow]%}:%{$fg[red]%}%a%{$fg[magenta]%}]%{$reset_color%}"
local vcs_formats_prefix="%F{magenta}(%F{white}%s%F{magenta})%f"
local vcs_formats_hyphen="%F{yellow}-%f"
local vcs_formats_normal="%F{magenta}[$vcs_clean_color%m%c%u%b%F{magenta}]%f"
local vcs_formats_action="%F{magenta}[$vcs_clean_color%m%c%u%b%F{yellow}:%F{red}%a%F{magenta}]%f"
zstyle ':vcs_info:*' formats " $vcs_formats_prefix$vcs_formats_hyphen$vcs_formats_normal"
zstyle ':vcs_info:*' actionformats " $vcs_formats_prefix$vcs_formats_hyphen$vcs_formats_action"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment