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

Introducing themes

parent 11adab31
Branches
No related tags found
No related merge requests found
...@@ -14,11 +14,11 @@ Info ...@@ -14,11 +14,11 @@ Info
| Color | State | Variable | | Color | State | Variable |
|:------:|:--------------------------:|:-----------------------------:| |:------:|:--------------------------:|:-----------------------------:|
| red | there are unstaged files | `OHMYVIA_VCS_UNSTAGED_COLOR` | | red | there are unstaged files | `OHMYVIA_VCS_COLOR_UNSTAGED` |
| yellow | there are staged files | `OHMYVIA_VCS_STAGED_COLOR` | | yellow | there are staged files | `OHMYVIA_VCS_COLOR_STAGED` |
| blue | there are untracked files | `OHMYVIA_VCS_UNTRACKED_COLOR` | | blue | there are untracked files | `OHMYVIA_VCS_COLOR_UNTRACKED` |
| cyan | stash stack is not empty | `OHMYVIA_VCS_STASH_COLOR` | | cyan | stash stack is not empty | `OHMYVIA_VCS_COLOR_STASH` |
| green | working directory is clean | `OHMYVIA_VCS_CLEAN_COLOR` | | green | working directory is clean | `OHMYVIA_VCS_COLOR_CLEAN` |
Usage Usage
...@@ -44,6 +44,7 @@ ZSH_THEME="oh-my-via/via" ...@@ -44,6 +44,7 @@ ZSH_THEME="oh-my-via/via"
Time format defaults to `%D{%H:%M}`, but can be overwritten by setting the variable Time format defaults to `%D{%H:%M}`, but can be overwritten by setting the variable
`OHMYVIA_TIME_FORMAT` in your `~/.zshrc`. `OHMYVIA_TIME_FORMAT` in your `~/.zshrc`.
VCS theme can be set through the variable `OHMYVIA_VCS_THEME`.
Testing Testing
------- -------
......
#
# functions/vcs_themes.zsh - provide sample themes for VCS prompt
#
# This work is free. You can redistribute it and/or modify it under the terms of
# the Do What The Fuck You Want To Public License, Version 2, as published by Sam
# Hocevar. See the COPYING file or http://www.wtfpl.net/ for more details.
#
# 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.
#› %a : An identifier that describes the action. Only makes sense in actionformats.
#› %i : The current revision number or identifier. For hg the hgrevformat style may be used to customize the output.
#› %c : The string from the stagedstr style if there are staged changes in the repository.
#› %u : The string from the unstagedstr style if there are unstaged changes in the repository.
#› %R : The base directory of the repository.
#› %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.
function +vi-theme-default() {
local vcs_prompt_prefix="%F{magenta}(%F{white}%s%F{magenta})%f"
local vcs_prompt_hyphen="%F{yellow}-%f"
local vcs_prompt_normal="%F{magenta}[%m%c%u%b%F{magenta}]%f"
local vcs_prompt_action="%F{magenta}[%m%c%u%b%F{magenta}|%F{red}%a%F{magenta}]%f"
OHMYVIA_VCS_PROMPT_NORMAL=${OHMYVIA_VCS_PROMPT_NORMAL:-"$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_normal"}
OHMYVIA_VCS_PROMPT_ACTION=${OHMYVIA_VCS_PROMPT_ACTION:-"$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_action"}
}
function +vi-theme-alphabet() {
local vcs_prompt_prefix="%F{magenta}(%F{white}%s%F{magenta})%f"
local vcs_prompt_hyphen="%F{yellow}-%f"
local vcs_prompt_normal="%F{magenta}[%m%c%u%b%F{magenta}]%f"
local vcs_prompt_action="%F{magenta}[%m%c%u%b %F{magenta}| %F{red}%a%F{magenta}]%f"
OHMYVIA_VCS_PROMPT_NORMAL="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_normal"
OHMYVIA_VCS_PROMPT_ACTION="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_action"
}
function +vi-theme-djou() {
local vcs_prompt_prefix="%F{white}%s%f"
local vcs_prompt_hyphen=" %F{yellow}-%f "
local vcs_prompt_normal="%m%c%u%b%f"
local vcs_prompt_action="%m%c%u%b %F{magenta}| %F{red}%a%f"
OHMYVIA_VCS_PROMPT_NORMAL="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_normal"
OHMYVIA_VCS_PROMPT_ACTION="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_action"
}
function +vi-theme-kiwi() {
local vcs_prompt_prefix="%F{magenta}(%F{white}%s%F{magenta})%f"
local vcs_prompt_hyphen="%F{yellow}-%f"
local vcs_prompt_normal="%F{magenta}[%m%c%u%b%F{magenta}]%f"
local vcs_prompt_action="%F{magenta}[%m%c%u%b%F{yellow}|%F{red}%a%F{magenta}]%f"
OHMYVIA_VCS_PROMPT_NORMAL="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_normal"
OHMYVIA_VCS_PROMPT_ACTION="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_action"
}
function +vi-theme-jon() {
local vcs_prompt_prefix=""
local vcs_prompt_hyphen=""
local vcs_prompt_normal="%F{magenta}[%m%c%u%b%F{magenta}]%f"
local vcs_prompt_action="%F{magenta}[%m%c%u%b%F{magenta}|%F{red}%a%F{magenta}]%f"
OHMYVIA_VCS_PROMPT_NORMAL="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_normal"
OHMYVIA_VCS_PROMPT_ACTION="$vcs_prompt_prefix$vcs_prompt_hyphen$vcs_prompt_action"
}
# vim: ft=zsh fenc=utf-8
#
# functions/vcs_utils.zsh - provide supplemental VCS functions
#
# This work is free. You can redistribute it and/or modify it under the terms of
# the Do What The Fuck You Want To Public License, Version 2, as published by Sam
# Hocevar. See the COPYING file or http://www.wtfpl.net/ for more details.
#
# 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]+=$OHMYVIA_VCS_COLOR_STASH
fi
}
# Thanks to https://github.com/sunaku/home/
function +vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
git status --porcelain | fgrep '??' &> /dev/null ; then
# This will show the marker if there are any untracked files in repo.
# 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]+=$OHMYVIA_VCS_COLOR_UNTRACKED
fi
}
# Erase hook_com[misc] ( ie. %m ) to avoid dealing with backends info outputs
# Add $vcs_clean_color to setup default %b coloring in vcs prompt
function +vi-misc-init() {
hook_com[misc]=$OHMYVIA_VCS_COLOR_CLEAN
}
# vim: ft=zsh fenc=utf-8
#
# VIA ZSH Theme - Preview: ASAP # VIA ZSH Theme - Preview: ASAP
# Fork from the historical VIA Centrale Réseaux ZSH Theme # Fork from the historical VIA Centrale Réseaux ZSH Theme
#
# This work is free. You can redistribute it and/or modify it under the terms of
# the Do What The Fuck You Want To Public License, Version 2, as published by Sam
# Hocevar. See the COPYING file or http://www.wtfpl.net/ for more details.
#
#################################################################################
# Source functions
#################################################################################
OHMYVIA_INSTALLATION_PATH="$(dirname "$0")"
source $OHMYVIA_INSTALLATION_PATH/functions/vcs_themes.zsh
source $OHMYVIA_INSTALLATION_PATH/functions/vcs_utils.zsh
#################################################################################
# Setup prompts
#################################################################################
local time_format=${OHMYVIA_TIME_FORMAT:-"%D{%H:%M}"} local time_format=${OHMYVIA_TIME_FORMAT:-"%D{%H:%M}"}
local clock="%B%F{cyan}$time_format%f%b" local clock="%B%F{cyan}$time_format%f%b"
...@@ -30,60 +49,23 @@ zstyle ':vcs_info:*' max-exports 1 # vcs_info only sets vcs_info_msg_0_ ...@@ -30,60 +49,23 @@ zstyle ':vcs_info:*' max-exports 1 # vcs_info only sets vcs_info_msg_0_
zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true # enable %c and %u sequences usage zstyle ':vcs_info:*' check-for-changes true # enable %c and %u sequences usage
local vcs_unstaged_color=${OHMYVIA_VCS_UNSTAGED_COLOR:-"%F{red}"} OHMYVIA_VCS_COLOR_UNSTAGED=${OHMYVIA_VCS_COLOR_UNSTAGED:-"%F{red}"}
local vcs_staged_color=${OHMYVIA_VCS_STAGED_COLOR:-"%F{yellow}"} OHMYVIA_VCS_COLOR_STAGED=${OHMYVIA_VCS_COLOR_STAGED:-"%F{yellow}"}
local vcs_untracked_color=${OHMYVIA_VCS_UNTRACKED_COLOR:-"%F{blue}"} OHMYVIA_VCS_COLOR_UNTRACKED=${OHMYVIA_VCS_COLOR_UNTRACKED:-"%F{blue}"}
local vcs_stash_color=${OHMYVIA_VCS_STASH_COLOR:-"%F{cyan}"} OHMYVIA_VCS_COLOR_STASH=${OHMYVIA_VCS_COLOR_STASH:-"%F{cyan}"}
local vcs_clean_color=${OHMYVIA_VCS_CLEAN_COLOR:-"%F{green}"} OHMYVIA_VCS_COLOR_CLEAN=${OHMYVIA_VCS_COLOR_CLEAN:-"%F{green}"}
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() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
git status --porcelain | fgrep '??' &> /dev/null ; then
# This will show the marker if there are any untracked files in repo.
# 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
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
fi
}
# Erase hook_com[misc] ( ie. %m ) to avoid dealing with backends info outputs zstyle ':vcs_info:*' unstagedstr $OHMYVIA_VCS_COLOR_UNSTAGED
# Add $vcs_clean_color to setup default %b coloring in vcs prompt zstyle ':vcs_info:*' stagedstr $OHMYVIA_VCS_COLOR_STAGED
function +vi-misc-init() {
hook_com[misc]=$vcs_clean_color
}
zstyle ':vcs_info:git*+set-message:*' hooks misc-init git-stash git-untracked zstyle ':vcs_info:git*+set-message:*' hooks misc-init git-stash git-untracked
# In normal formats and actionformats the following replacements are done: # Load VCS theme
# %s : The VCS in use (git, hg, svn, etc.). OHMYVIA_VCS_THEME=${OHMYVIA_VCS_THEME:-"default"}
# %b : Information about the current branch. eval +vi-theme-$OHMYVIA_VCS_THEME
# %a : An identifier that describes the action. Only makes sense in actionformats.
# %i : The current revision number or identifier. For hg the hgrevformat style may be used to customize the output. zstyle ':vcs_info:*' formats " $OHMYVIA_VCS_PROMPT_NORMAL"
# %c : The string from the stagedstr style if there are staged changes in the repository. zstyle ':vcs_info:*' actionformats " $OHMYVIA_VCS_PROMPT_ACTION"
# %u : The string from the unstagedstr style if there are unstaged changes in the repository.
# %R : The base directory of the repository.
# %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="%F{magenta}(%F{white}%s%F{magenta})%f"
local vcs_formats_hyphen="%F{yellow}-%f"
local vcs_formats_normal="%F{magenta}[%m%c%u%b%F{magenta}]%f"
local vcs_formats_action="%F{magenta}[%m%c%u%b%F{magenta}|%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"
precmd () { vcs_info } precmd () { vcs_info }
RPROMPT='${vcs_info_msg_0_}' RPROMPT='${vcs_info_msg_0_}'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment