mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-11 00:00:06 +00:00
start massive refactoring of config params
This commit is contained in:
parent
5ef0ec415e
commit
d63fd9a873
6 changed files with 889 additions and 948 deletions
|
@ -1,14 +1,6 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
################################################################
|
||||
# Color functions
|
||||
# This file holds some color-functions for
|
||||
# the powerlevel9k-ZSH-theme
|
||||
# https://github.com/bhilburn/powerlevel9k
|
||||
################################################################
|
||||
|
||||
# https://jonasjacek.github.io/colors/
|
||||
# use color names by default to allow dark/light themes to adjust colors based on names
|
||||
typeset -gAh __P9K_COLORS=(
|
||||
# For compatibility with Powerlevel9k. It's not recommended to use mnemonic color
|
||||
# names in the configuration except for colors 0-7 as these are standard.
|
||||
typeset -grA __p9k_colors=(
|
||||
black 000
|
||||
red 001
|
||||
green 002
|
||||
|
@ -269,23 +261,25 @@ typeset -gAh __P9K_COLORS=(
|
|||
grey93 255
|
||||
)
|
||||
|
||||
# For user convenience: type `getColorCode background` or `getColorCode foreground` to see
|
||||
# the list of predefined colors.
|
||||
# For compatibility with Powerlevel9k.
|
||||
#
|
||||
# Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors.
|
||||
function getColorCode() {
|
||||
emulate -L zsh
|
||||
if (( ARGC == 1 )); then
|
||||
case $1 in
|
||||
foreground)
|
||||
local k
|
||||
for k in "${(k@)__P9K_COLORS}"; do
|
||||
local v=${__P9K_COLORS[$k]}
|
||||
for k in "${(k@)__p9k_colors}"; do
|
||||
local v=${__p9k_colors[$k]}
|
||||
print -P "%F{$v}$v - $k%f"
|
||||
done
|
||||
return
|
||||
;;
|
||||
background)
|
||||
local k
|
||||
for k in "${(k@)__P9K_COLORS}"; do
|
||||
local v=${__P9K_COLORS[$k]}
|
||||
for k in "${(k@)__p9k_colors}"; do
|
||||
local v=${__p9k_colors[$k]}
|
||||
print -P "%K{$v}$v - $k%k"
|
||||
done
|
||||
return
|
||||
|
|
|
@ -1,34 +1,15 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
################################################################
|
||||
# icons
|
||||
# This file holds the icon definitions and
|
||||
# icon-functions for the powerlevel9k-ZSH-theme
|
||||
# https://github.com/bhilburn/powerlevel9k
|
||||
################################################################
|
||||
|
||||
# These characters require the Powerline fonts to work properly. If you see
|
||||
# boxes or bizarre characters below, your fonts are not correctly installed. If
|
||||
# you do not want to install a special font, you can set `POWERLEVEL9K_MODE` to
|
||||
# `compatible`. This shows all icons in regular symbols.
|
||||
|
||||
# Initialize the icon list according to the user's `POWERLEVEL9K_MODE`.
|
||||
typeset -gAH icons
|
||||
|
||||
set_default POWERLEVEL9K_HIDE_BRANCH_ICON false
|
||||
set_default POWERLEVEL9K_MODE ""
|
||||
|
||||
typeset -gi _P9K_ICONS_INITIALIZED=0
|
||||
typeset -gA icons
|
||||
|
||||
function _p9k_init_icons() {
|
||||
(( _P9K_ICONS_INITIALIZED )) && return
|
||||
_P9K_ICONS_INITIALIZED=1
|
||||
[[ $+_p9k_icon_mode && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return
|
||||
typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE
|
||||
|
||||
local LC_ALL=C.UTF-8
|
||||
|
||||
case $POWERLEVEL9K_MODE in
|
||||
'flat'|'awesome-patched')
|
||||
# Awesome-Patched Font required! See:
|
||||
# https://github.com/gabrielelana/awesome-terminal-fonts/tree/patching-strategy/patched
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons=(
|
||||
RULER_CHAR $'\u2500' # ─
|
||||
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
|
||||
|
@ -131,8 +112,6 @@ function _p9k_init_icons() {
|
|||
'awesome-fontconfig')
|
||||
# fontconfig with awesome-font required! See
|
||||
# https://github.com/gabrielelana/awesome-terminal-fonts
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons=(
|
||||
RULER_CHAR $'\u2500' # ─
|
||||
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
|
||||
|
@ -232,16 +211,12 @@ function _p9k_init_icons() {
|
|||
# mapped fontconfig with awesome-font required! See
|
||||
# https://github.com/gabrielelana/awesome-terminal-fonts
|
||||
# don't forget to source the font maps in your startup script
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
|
||||
if [ -z "$AWESOME_GLYPHS_LOADED" ]; then
|
||||
echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded.
|
||||
Source a font mapping in your shell config, per the Awesome-Font docs
|
||||
(https://github.com/gabrielelana/awesome-terminal-fonts),
|
||||
Or use a different Powerlevel9k font configuration.";
|
||||
fi
|
||||
|
||||
icons=(
|
||||
RULER_CHAR $'\u2500' # ─
|
||||
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
|
||||
|
@ -337,8 +312,6 @@ function _p9k_init_icons() {
|
|||
# nerd-font patched (complete) font required! See
|
||||
# https://github.com/ryanoasis/nerd-fonts
|
||||
# http://nerdfonts.com/#cheat-sheet
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons=(
|
||||
RULER_CHAR $'\u2500' # ─
|
||||
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
|
||||
|
@ -437,8 +410,6 @@ function _p9k_init_icons() {
|
|||
*)
|
||||
# Powerline-Patched Font required!
|
||||
# See https://github.com/Lokaltog/powerline-fonts
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons=(
|
||||
RULER_CHAR $'\u2500' # ─
|
||||
LEFT_SEGMENT_SEPARATOR $'\uE0B0' #
|
||||
|
@ -539,30 +510,22 @@ function _p9k_init_icons() {
|
|||
# Override the above icon settings with any user-defined variables.
|
||||
case $POWERLEVEL9K_MODE in
|
||||
'flat')
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons[LEFT_SEGMENT_SEPARATOR]=''
|
||||
icons[RIGHT_SEGMENT_SEPARATOR]=''
|
||||
icons[LEFT_SUBSEGMENT_SEPARATOR]='|'
|
||||
icons[RIGHT_SUBSEGMENT_SEPARATOR]='|'
|
||||
;;
|
||||
'compatible')
|
||||
# Set the right locale to protect special characters
|
||||
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
|
||||
icons[LEFT_SEGMENT_SEPARATOR]=$'\u2B80' # ⮀
|
||||
icons[RIGHT_SEGMENT_SEPARATOR]=$'\u2B82' # ⮂
|
||||
icons[VCS_BRANCH_ICON]='@'
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$POWERLEVEL9K_HIDE_BRANCH_ICON" == true ]]; then
|
||||
icons[VCS_BRANCH_ICON]=''
|
||||
fi
|
||||
}
|
||||
|
||||
# Safety function for printing icons
|
||||
# Prints the named icon, or if that icon is undefined, the string name.
|
||||
# Sadly, this is a part of public API. Its use is emphatically discouraged.
|
||||
function print_icon() {
|
||||
emulate -L zsh
|
||||
_p9k_init_icons
|
||||
local icon_name=$1
|
||||
local var_name=POWERLEVEL9K_${icon_name}
|
||||
|
@ -573,11 +536,13 @@ function print_icon() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Get a list of configured icons
|
||||
# Prints a list of configured icons.
|
||||
#
|
||||
# * $1 string - If "original", then the original icons are printed,
|
||||
# otherwise "print_icon" is used, which takes the users
|
||||
# overrides into account.
|
||||
function get_icon_names() {
|
||||
emulate -L zsh
|
||||
_p9k_init_icons
|
||||
# Iterate over a ordered list of keys of the icons array
|
||||
for key in ${(@kon)icons}; do
|
||||
|
|
|
@ -1,48 +1,46 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
################################################################
|
||||
# Utility functions
|
||||
# This file holds some utility-functions for
|
||||
# the powerlevel9k-ZSH-theme
|
||||
# https://github.com/bhilburn/powerlevel9k
|
||||
################################################################
|
||||
|
||||
# Usage: set_default [OPTION]... NAME [VALUE]...
|
||||
#
|
||||
# Options are the same as in `typeset`.
|
||||
function set_default() {
|
||||
emulate -L zsh
|
||||
local -a flags=(-g)
|
||||
while true; do
|
||||
case $1 in
|
||||
--) shift; break;;
|
||||
-*) flags+=$1; shift;;
|
||||
*) break;
|
||||
esac
|
||||
done
|
||||
|
||||
local varname=$1
|
||||
shift
|
||||
if [[ -n ${(tP)varname} ]]; then
|
||||
typeset $flags $varname
|
||||
elif [[ "$flags" == *[aA]* ]]; then
|
||||
eval "typeset ${(@q)flags} ${(q)varname}=(${(qq)@})"
|
||||
else
|
||||
typeset $flags $varname="$*"
|
||||
fi
|
||||
}
|
||||
|
||||
function _p9k_g_expand() {
|
||||
(( $+parameters[$1] )) || return
|
||||
local -a ts=("${=$(typeset -p $1)}")
|
||||
shift ts
|
||||
local x
|
||||
for x in "${ts[@]}"; do
|
||||
[[ $x == -* ]] || break
|
||||
# Don't change readonly variables. Ideally, we shouldn't modify any variables at all,
|
||||
# but for now this will do.
|
||||
[[ $x == -*r* ]] && return
|
||||
done
|
||||
typeset -g $1=${(g::)${(P)1}}
|
||||
# _p9k_declare <type> <uppercase-name> [default]...
|
||||
function _p9k_declare() {
|
||||
local -i set=$+parameters[$2]
|
||||
(( ARGC > 2 || set )) || return 0
|
||||
case $1 in
|
||||
-b)
|
||||
if (( set )); then
|
||||
[[ ${(P)2} == true ]] && typeset -gi _$2=1 || typeset -gi _$2=0
|
||||
else
|
||||
typeset -gi _$2=$3
|
||||
fi
|
||||
;;
|
||||
-a)
|
||||
local -a v=(${(P)2})
|
||||
if (( set )); then
|
||||
eval "typeset -ga _${(q)2}=(${(@qq)v})";
|
||||
else
|
||||
if [[ $3 != '--' ]]; then
|
||||
echo "internal error in _p9k_declare " "${(qqq)@}" >&2
|
||||
fi
|
||||
eval "typeset -ga _${(q)2}=(${(@qq)*[4,-1]})"
|
||||
fi
|
||||
;;
|
||||
-i)
|
||||
(( set )) && typeset -gi _$2=$2 || typeset -gi _$2=$3
|
||||
;;
|
||||
-F)
|
||||
(( set )) && typeset -gF _$2=$2 || typeset -gF _$2=$3
|
||||
;;
|
||||
-s)
|
||||
(( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3
|
||||
;;
|
||||
-e)
|
||||
if (( set )); then
|
||||
local v=${(P)2}
|
||||
typeset -g _$2=${(g::)v}
|
||||
else
|
||||
typeset -g _$2=${(g::)3}
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "internal error in _p9k_declare " "${(qqq)@}" >&2
|
||||
esac
|
||||
}
|
||||
|
||||
# If we execute `print -P $1`, how many characters will be printed on the last line?
|
||||
|
@ -69,21 +67,21 @@ function _p9k_prompt_length() {
|
|||
typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m
|
||||
done
|
||||
fi
|
||||
_P9K_RETVAL=$x
|
||||
_p9k_ret=$x
|
||||
}
|
||||
|
||||
typeset -g _P9K_BYTE_SUFFIX=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y')
|
||||
typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y')
|
||||
|
||||
# 42 => 42B
|
||||
# 1536 => 1.5K
|
||||
function _p9k_human_readable_bytes() {
|
||||
typeset -F 2 n=$1
|
||||
local suf
|
||||
for suf in $_P9K_BYTE_SUFFIX; do
|
||||
for suf in $__p9k_byte_suffix; do
|
||||
(( n < 100 )) && break
|
||||
(( n /= 1024 ))
|
||||
done
|
||||
_P9K_RETVAL=$n$suf
|
||||
_p9k_ret=$n$suf
|
||||
}
|
||||
|
||||
# Determine if the passed segment is used in the prompt
|
||||
|
@ -92,11 +90,10 @@ function _p9k_human_readable_bytes() {
|
|||
# either the LEFT or RIGHT prompt arrays.
|
||||
# * $1: The segment to be tested.
|
||||
segment_in_use() {
|
||||
local key=$1
|
||||
[[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)${key}]}" ||
|
||||
-n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)${key}_joined]}" ||
|
||||
-n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)${key}]}" ||
|
||||
-n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)${key}_joined]}" ]]
|
||||
[[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)${1}]}" ||
|
||||
-n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)${1}_joined]}" ||
|
||||
-n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)${1}]}" ||
|
||||
-n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)${1}_joined]}" ]]
|
||||
}
|
||||
|
||||
function _p9k_parse_ip() {
|
||||
|
@ -120,7 +117,7 @@ function _p9k_parse_ip() {
|
|||
local ipFound="${match[3]}"
|
||||
local -a interfaceStates=(${(s:,:)match[1]})
|
||||
if (( ${interfaceStates[(I)UP]} )); then
|
||||
_P9K_RETVAL=$ipFound
|
||||
_p9k_ret=$ipFound
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
@ -132,7 +129,7 @@ function _p9k_parse_ip() {
|
|||
local interface
|
||||
for interface in "${(@)interfaces}"; do
|
||||
if [[ "$interface" =~ $pattern ]]; then
|
||||
_P9K_RETVAL=$match[1]
|
||||
_p9k_ret=$match[1]
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
################################################################
|
||||
# vcs
|
||||
# This file holds supplemental VCS functions
|
||||
# for the powerlevel9k-ZSH-theme
|
||||
# https://github.com/bhilburn/powerlevel9k
|
||||
################################################################
|
||||
|
||||
set_default POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY false
|
||||
function +vi-git-untracked() {
|
||||
[[ -z "${vcs_comm[gitdir]}" || "${vcs_comm[gitdir]}" == "." ]] && return
|
||||
|
||||
|
@ -17,7 +8,7 @@ function +vi-git-untracked() {
|
|||
|
||||
local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)
|
||||
|
||||
if [[ -z $untrackedFiles && "$POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY" == "true" ]]; then
|
||||
if [[ -z $untrackedFiles && $_POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY == 1 ]]; then
|
||||
untrackedFiles+=$(command git submodule foreach --quiet --recursive 'command git ls-files --others --exclude-standard' 2> /dev/null)
|
||||
fi
|
||||
|
||||
|
@ -51,20 +42,24 @@ function +vi-git-remotebranch() {
|
|||
# Are we on a remote-tracking branch?
|
||||
remote=${$(command git rev-parse --verify HEAD@{upstream} --symbolic-full-name 2>/dev/null)/refs\/(remotes|heads)\/}
|
||||
|
||||
if [[ -n "$POWERLEVEL9K_VCS_SHORTEN_LENGTH" ]] && [[ -n "$POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH" ]]; then
|
||||
if [ ${#hook_com[branch]} -gt ${POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH} ] && [ ${#hook_com[branch]} -gt ${POWERLEVEL9K_VCS_SHORTEN_LENGTH} ]; then
|
||||
case "$POWERLEVEL9K_VCS_SHORTEN_STRATEGY" in
|
||||
if (( $+_POWERLEVEL9K_VCS_SHORTEN_LENGTH && $+_POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH )); then
|
||||
if (( ${#hook_com[branch]} > _POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && ${#hook_com[branch]} > _POWERLEVEL9K_VCS_SHORTEN_LENGTH )); then
|
||||
case $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY in
|
||||
truncate_middle)
|
||||
hook_com[branch]="${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}${POWERLEVEL9K_VCS_SHORTEN_DELIMITER}${branch_name: -$POWERLEVEL9K_VCS_SHORTEN_LENGTH}"
|
||||
hook_com[branch]="${branch_name:0:$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER}${branch_name: -$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}"
|
||||
;;
|
||||
truncate_from_right)
|
||||
hook_com[branch]="${branch_name:0:$POWERLEVEL9K_VCS_SHORTEN_LENGTH}${POWERLEVEL9K_VCS_SHORTEN_DELIMITER}"
|
||||
hook_com[branch]="${branch_name:0:$_POWERLEVEL9K_VCS_SHORTEN_LENGTH}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
|
||||
if (( _POWERLEVEL9K_HIDE_BRANCH_ICON )); then
|
||||
hook_com[branch]="${hook_com[branch]}"
|
||||
else
|
||||
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${hook_com[branch]}"
|
||||
fi
|
||||
# Always show the remote
|
||||
#if [[ -n ${remote} ]] ; then
|
||||
# Only show the remote if it differs from the local
|
||||
|
@ -73,30 +68,33 @@ function +vi-git-remotebranch() {
|
|||
fi
|
||||
}
|
||||
|
||||
set_default POWERLEVEL9K_VCS_HIDE_TAGS false
|
||||
function +vi-git-tagname() {
|
||||
if [[ "$POWERLEVEL9K_VCS_HIDE_TAGS" == "false" ]]; then
|
||||
# If we are on a tag, append the tagname to the current branch string.
|
||||
local tag
|
||||
tag=$(command git describe --tags --exact-match HEAD 2>/dev/null)
|
||||
if (( !_POWERLEVEL9K_VCS_HIDE_TAGS )); then
|
||||
# If we are on a tag, append the tagname to the current branch string.
|
||||
local tag
|
||||
tag=$(command git describe --tags --exact-match HEAD 2>/dev/null)
|
||||
|
||||
if [[ -n "${tag}" ]] ; then
|
||||
# There is a tag that points to our current commit. Need to determine if we
|
||||
# are also on a branch, or are in a DETACHED_HEAD state.
|
||||
if [[ -z $(command git symbolic-ref HEAD 2>/dev/null) ]]; then
|
||||
# DETACHED_HEAD state. We want to append the tag name to the commit hash
|
||||
# and print it. Unfortunately, `vcs_info` blows away the hash when a tag
|
||||
# exists, so we have to manually retrieve it and clobber the branch
|
||||
# string.
|
||||
local revision
|
||||
revision=$(command git rev-list -n 1 --abbrev-commit --abbrev=${POWERLEVEL9K_VCS_INTERNAL_HASH_LENGTH} HEAD)
|
||||
if [[ -n "${tag}" ]] ; then
|
||||
# There is a tag that points to our current commit. Need to determine if we
|
||||
# are also on a branch, or are in a DETACHED_HEAD state.
|
||||
if [[ -z $(command git symbolic-ref HEAD 2>/dev/null) ]]; then
|
||||
# DETACHED_HEAD state. We want to append the tag name to the commit hash
|
||||
# and print it. Unfortunately, `vcs_info` blows away the hash when a tag
|
||||
# exists, so we have to manually retrieve it and clobber the branch
|
||||
# string.
|
||||
local revision
|
||||
revision=$(command git rev-list -n 1 --abbrev-commit --abbrev=${_POWERLEVEL9K_CHANGESET_HASH_LENGTH} HEAD)
|
||||
if (( _POWERLEVEL9K_HIDE_BRANCH_ICON )); then
|
||||
hook_com[branch]="${revision} $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||
else
|
||||
hook_com[branch]="$(print_icon 'VCS_BRANCH_ICON')${revision} $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||
else
|
||||
# We are on both a tag and a branch; print both by appending the tag name.
|
||||
hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# We are on both a tag and a branch; print both by appending the tag name.
|
||||
hook_com[branch]+=" $(print_icon 'VCS_TAG_ICON')${tag}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Show count of stashed changes
|
||||
|
|
1556
internal/p10k.zsh
1556
internal/p10k.zsh
File diff suppressed because it is too large
Load diff
|
@ -20,32 +20,33 @@ fi
|
|||
() {
|
||||
emulate -L zsh
|
||||
|
||||
if (( $+_p9k_sourced )); then
|
||||
if (( $+__p9k_sourced )); then
|
||||
prompt_powerlevel9k_setup
|
||||
return
|
||||
fi
|
||||
typeset -gr _p9k_sourced=1
|
||||
typeset -g _p9k_installation_dir=''
|
||||
typeset -gr __p9k_sourced=1
|
||||
typeset -g __p9k_installation_dir=''
|
||||
|
||||
if [[ -n $POWERLEVEL9K_INSTALLATION_DIR ]]; then
|
||||
_p9k_installation_dir=${POWERLEVEL9K_INSTALLATION_DIR:A}
|
||||
__p9k_installation_dir=${POWERLEVEL9K_INSTALLATION_DIR:A}
|
||||
else
|
||||
if [[ ${(%):-%N} == '(eval)' ]]; then
|
||||
if [[ $0 == '-antigen-load' && -r powerlevel9k.zsh-theme ]]; then
|
||||
# Antigen uses eval to load things so it can change the plugin (!!)
|
||||
# https://github.com/zsh-users/antigen/issues/581
|
||||
_p9k_installation_dir=$PWD
|
||||
__p9k_installation_dir=$PWD
|
||||
else
|
||||
>&2 print -P '%F{red}[ERROR]%f Powerlevel10k cannot figure out its installation directory.'
|
||||
>&2 print -P 'Please set %F{green}POWERLEVEL9K_INSTALLATION_DIR.%f'
|
||||
return 1
|
||||
return
|
||||
fi
|
||||
else
|
||||
_p9k_installation_dir=${${(%):-%x}:A:h}
|
||||
__p9k_installation_dir=${${(%):-%x}:A:h}
|
||||
fi
|
||||
fi
|
||||
|
||||
source $_p9k_installation_dir/internal/p10k.zsh
|
||||
typeset -gr __p9k_installation_dir
|
||||
source $__p9k_installation_dir/internal/p10k.zsh || true
|
||||
}
|
||||
|
||||
(( ! _p9k_restore_aliases )) || setopt aliases
|
||||
|
|
Loading…
Reference in a new issue