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

Expanding full hostname as default behavior

parent 870a5128
Branches
No related tags found
No related merge requests found
......@@ -54,6 +54,9 @@ ZSH_THEME="oh-my-via/via"
Time format defaults to `%D{%H:%M}`, but can be overwritten by setting the variable
`OHMYVIA_TIME_FORMAT` in your `~/.zshrc`.
Hostname may be printed up to the first `.` or hidden with the variable
`OHMYVIA_CONTEXT_HOSTNAME`.
VCS theme can be set through the variable `OHMYVIA_VCS_THEME`.
......
......@@ -10,8 +10,23 @@
# 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"
# Return only username if $OHMYVIA_CONTEXT_HOSTNAME is empty.
if [[ $OHMYVIA_CONTEXT_HOSTNAME == "empty" ]]; then
echo "${username}"
return
fi
local separator="$OHMYVIA_CONTEXT_SEPARATOR_COLOR@%b%f"
local hostname="$OHMYVIA_CONTEXT_HOSTNAME_COLOR%m%b%f"
# Handle hostnames containing `.` (defaults to full machine hostname prompt.)
local colorless_hostname="$OHMYVIA_CONTEXT_HOSTNAME"
if [[ $OHMYVIA_CONTEXT_HOSTNAME == 'full' ]]; then
colorless_hostname="%M"
elif [[ $OHMYVIA_CONTEXT_HOSTNAME == 'partial' ]]; then
colorless_hostname="%m"
fi
local hostname="$OHMYVIA_CONTEXT_HOSTNAME_COLOR${colorless_hostname}%b%f"
echo "${username}${separator}${hostname}"
}
......
......@@ -24,6 +24,7 @@ source $OHMYVIA_INSTALLATION_PATH/functions/vcs_utils.zsh
## Properties
set_default OHMYVIA_CONTEXT_HOSTNAME "full"
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}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment