diff --git a/functions/prompt_utils.zsh b/functions/prompt_utils.zsh new file mode 100644 index 0000000000000000000000000000000000000000..cb97b975eb5dfb426eded1cf7844471a6d6b98ae --- /dev/null +++ b/functions/prompt_utils.zsh @@ -0,0 +1,35 @@ +# +# 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 + diff --git a/via.zsh-theme b/via.zsh-theme index fc16329869451604198396085bac33bfbd96085b..0953d2748caf395671c01135aff5e87cc7f51603 100644 --- a/via.zsh-theme +++ b/via.zsh-theme @@ -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 ################################################################################# -set_default OHMYVIA_TIME_FORMAT "%D{%H:%M}" +## Properties -set_default OHMYVIA_VCS_COLOR_UNSTAGED "red" -set_default OHMYVIA_VCS_COLOR_STAGED "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" +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}" -################################################################################# -# Setup prompts -################################################################################# +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}" -local clock="%B%F{cyan}$OHMYVIA_TIME_FORMAT%f%b" +set_default OHMYVIA_TIME_COLOR "%B%F{cyan}" +set_default OHMYVIA_TIME_FORMAT "%D{%H:%M}" -local user="%B%(!.%F{blue}.%F{red})%n%f%b" +set_default OHMYVIA_VCS_COLOR_UNSTAGED "red" +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" -local user_host="${user}%B%F{yellow}@%F{white}%m%f%b" -local current_dir="%B%F{green}%~%f%b" +################################################################################# +# Build left & right prompts +################################################################################# -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