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

Adding config variables

In order to clean the main file, many functions have been moved to
another file. Customization through envvar is now easier, but still
not documented.
parent 3c89d4ed
No related branches found
No related tags found
No related merge requests found
#
# functions/prompt_utils.zsh - provide prompt definitions
#
# 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.
#
# Context: user@hostname (who am I and where am I)
# See https://github.com/bhilburn/powerlevel9k/blob/1ff9da64d974265ce2f22bd1da4a47d0b8f7ca90/powerlevel9k.zsh-theme#L434
prompt_context () {
local username="%(!.$OHMYVIA_CONTEXT_ROOT_COLOR.$OHMYVIA_CONTEXT_USER_COLOR)%n%b%f"
local separator="$OHMYVIA_CONTEXT_SEPARATOR_COLOR@%b%f"
local hostname="$OHMYVIA_CONTEXT_HOSTNAME_COLOR%m%b%f"
echo "${username}${separator}${hostname}"
}
# Print current directory with ~ instead of $HOME
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Shell-state
prompt_dir () {
local current_dir="$OHMYVIA_DIR_COLOR%~%b%f"
echo $current_dir
}
# Print current time
prompt_time () {
local clock="$OHMYVIA_TIME_COLOR$OHMYVIA_TIME_FORMAT%b%f"
echo $clock
}
# vim: ft=zsh fenc=utf-8
......@@ -13,6 +13,7 @@
OHMYVIA_INSTALLATION_PATH="$(dirname "$0")"
source $OHMYVIA_INSTALLATION_PATH/functions/prompt_utils.zsh
source $OHMYVIA_INSTALLATION_PATH/functions/utils.zsh
source $OHMYVIA_INSTALLATION_PATH/functions/vcs_themes.zsh
source $OHMYVIA_INSTALLATION_PATH/functions/vcs_utils.zsh
......@@ -21,30 +22,36 @@ source $OHMYVIA_INSTALLATION_PATH/functions/vcs_utils.zsh
# Variables initialization
#################################################################################
## Properties
set_default OHMYVIA_CONTEXT_HOSTNAME_COLOR "%B%F{white}"
set_default OHMYVIA_CONTEXT_SEPARATOR_COLOR "%B%F{yellow}"
set_default OHMYVIA_CONTEXT_ROOT_COLOR "%B%F{blue}"
set_default OHMYVIA_CONTEXT_USER_COLOR "%B%F{red}"
set_default OHMYVIA_DIR_COLOR "%B%F{green}"
set_default OHMYVIA_STATUS_OK_COLOR "%B%F{yellow}"
set_default OHMYVIA_STATUS_ERROR_COLOR "%B%F{red}"
set_default OHMYVIA_TIME_COLOR "%B%F{cyan}"
set_default OHMYVIA_TIME_FORMAT "%D{%H:%M}"
set_default OHMYVIA_VCS_COLOR_UNSTAGED "red"
set_default OHMYVIA_VCS_COLOR_STAGED "yellow"
set_default OHMYVIA_VCS_COLOR_STAGE "yellow"
set_default OHMYVIA_VCS_COLOR_UNTRACKED "blue"
set_default OHMYVIA_VCS_COLOR_STASH "cyan"
set_default OHMYVIA_VCS_COLOR_CLEAN "green"
set_default OHMYVIA_VCS_THEME "default"
#################################################################################
# Setup prompts
# Build left & right prompts
#################################################################################
local clock="%B%F{cyan}$OHMYVIA_TIME_FORMAT%f%b"
local user="%B%(!.%F{blue}.%F{red})%n%f%b"
local user_host="${user}%B%F{yellow}@%F{white}%m%f%b"
local current_dir="%B%F{green}%~%f%b"
local eol="%B%(?.%F{yellow}.%F{red})%#%f%b"
OHMYVIA_EOL="%(?.$OHMYVIA_STATUS_OK_COLOR.$OHMYVIA_STATUS_ERROR_COLOR)%#%f%b"
PROMPT='${clock} ${user_host} ${current_dir}${eol} '
PROMPT="$(prompt_time) $(prompt_context) $(prompt_dir)${OHMYVIA_EOL} "
# Display vcs info
# http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment