Merge branch 'master' of github.com:romkatv/powerlevel10k into vcs_fix

This commit is contained in:
jD4rk 2020-02-07 18:16:08 +01:00
commit 2070f34df3
6 changed files with 278 additions and 108 deletions

View File

@ -528,6 +528,45 @@
# Default asdf color. Only used to display tools for which there is no color override (see below).
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66
# There are three parameters that can be used to hide tools. If at least one of them decides
# to hide a tool, that tool gets hidden. POWERLEVEL9K_ASDF_SHOW_SYSTEM=false hides "system". To
# see the difference between POWERLEVEL9K_ASDF_SOURCES and POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW
# consider the effect of the following commands:
#
# asdf local python 3.8.1
# asdf global python 3.8.1
#
# After running both commands the current python version is 3.8.1 and its source is "local" as
# it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false,
# it'll hide python version in this case because 3.8.1 is the same as the global version.
# POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't
# contain "local".
# Hide tool versions that don't come from one of these sources.
#
# Available sources:
#
# - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable"
# - local `asdf current` says "set by /some/not/home/directory/file"
# - global `asdf current` says "set by /home/username/file"
#
# Note: If this parameter is set to (shell local global), it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES.
typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global)
# If set to false, hide tool versions that are the same as global.
#
# Note: The name of this parameter doesn't reflect its meaning at all.
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW.
typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false
# If set to false, hide tool versions that are equal to "system".
#
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM.
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# Ruby version from asdf.
typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168
# typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐'

View File

@ -529,6 +529,45 @@
# Default asdf color. Only used to display tools for which there is no color override (see below).
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=6
# There are three parameters that can be used to hide tools. If at least one of them decides
# to hide a tool, that tool gets hidden. POWERLEVEL9K_ASDF_SHOW_SYSTEM=false hides "system". To
# see the difference between POWERLEVEL9K_ASDF_SOURCES and POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW
# consider the effect of the following commands:
#
# asdf local python 3.8.1
# asdf global python 3.8.1
#
# After running both commands the current python version is 3.8.1 and its source is "local" as
# it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false,
# it'll hide python version in this case because 3.8.1 is the same as the global version.
# POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't
# contain "local".
# Hide tool versions that don't come from one of these sources.
#
# Available sources:
#
# - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable"
# - local `asdf current` says "set by /some/not/home/directory/file"
# - global `asdf current` says "set by /home/username/file"
#
# Note: If this parameter is set to (shell local global), it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES.
typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global)
# If set to false, hide tool versions that are the same as global.
#
# Note: The name of this parameter doesn't reflect its meaning at all.
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW.
typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false
# If set to false, hide tool versions that are equal to "system".
#
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM.
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# Ruby version from asdf.
typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=1
# typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐'

View File

@ -529,6 +529,45 @@
# Default asdf color. Only used to display tools for which there is no color override (see below).
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66
# There are three parameters that can be used to hide tools. If at least one of them decides
# to hide a tool, that tool gets hidden. POWERLEVEL9K_ASDF_SHOW_SYSTEM=false hides "system". To
# see the difference between POWERLEVEL9K_ASDF_SOURCES and POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW
# consider the effect of the following commands:
#
# asdf local python 3.8.1
# asdf global python 3.8.1
#
# After running both commands the current python version is 3.8.1 and its source is "local" as
# it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false,
# it'll hide python version in this case because 3.8.1 is the same as the global version.
# POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't
# contain "local".
# Hide tool versions that don't come from one of these sources.
#
# Available sources:
#
# - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable"
# - local `asdf current` says "set by /some/not/home/directory/file"
# - global `asdf current` says "set by /home/username/file"
#
# Note: If this parameter is set to (shell local global), it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES.
typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global)
# If set to false, hide tool versions that are the same as global.
#
# Note: The name of this parameter doesn't reflect its meaning at all.
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW.
typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false
# If set to false, hide tool versions that are equal to "system".
#
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM.
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# Ruby version from asdf.
typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168
# typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐'

View File

@ -531,6 +531,45 @@
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=0
typeset -g POWERLEVEL9K_ASDF_BACKGROUND=7
# There are three parameters that can be used to hide tools. If at least one of them decides
# to hide a tool, that tool gets hidden. POWERLEVEL9K_ASDF_SHOW_SYSTEM=false hides "system". To
# see the difference between POWERLEVEL9K_ASDF_SOURCES and POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW
# consider the effect of the following commands:
#
# asdf local python 3.8.1
# asdf global python 3.8.1
#
# After running both commands the current python version is 3.8.1 and its source is "local" as
# it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false,
# it'll hide python version in this case because 3.8.1 is the same as the global version.
# POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't
# contain "local".
# Hide tool versions that don't come from one of these sources.
#
# Available sources:
#
# - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable"
# - local `asdf current` says "set by /some/not/home/directory/file"
# - global `asdf current` says "set by /home/username/file"
#
# Note: If this parameter is set to (shell local global), it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES.
typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global)
# If set to false, hide tool versions that are the same as global.
#
# Note: The name of this parameter doesn't reflect its meaning at all.
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW.
typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false
# If set to false, hide tool versions that are equal to "system".
#
# Note: If this parameter is set to true, it won't hide tools.
# Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM.
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# Ruby version from asdf.
typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=0
typeset -g POWERLEVEL9K_ASDF_RUBY_BACKGROUND=1

View File

@ -8,49 +8,4 @@
disabling implicit reset on every eval in _p9k_worker_receive.
- implement fake gitstatus api on top of vcs_info (or plain git?) + worker and use it if there is no
gitstatus.
## asdf
- https://asdf-vm.com/#/core-configuration?id=environment-variables
- https://asdf-vm.com/#/core-configuration?id=tool-versions
- https://asdf-vm.com/#/core-configuration?id=homeasdfrc
- https://asdf-vm.com/#/plugins-create?id=binlist-legacy-filenames
- https://asdf-vm.com/#/plugins-create?id=binparse-legacy-file
- `print -lr -- ${ASDF_DATA_DIR:-~/.asdf}/plugins/*(/N:t)`
- `print -lr -- $(${ASDF_DATA_DIR:-~/.asdf}/plugins/ruby/bin/list-legacy-filenames)`
- `${ASDF_DATA_DIR:-~/.asdf}/plugins/ruby/bin/parse-legacy-file ~/powerlevel10k/test/foo/.ruby-version`
- if empty, keep looking
- ASDF_${upcase_name}_VERSION wins over everything
- deeper version overrides win
- .tool-versions wins over .ruby-version when in the same directory
- versions for different tools are looked up independently: if /foo/bar/.tool-versions doesn't
override "ruby" it's as if it doesn't exist as far as ruby version is concerned.
- after upglob look $HOME (same file patterns)
- finally look at $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME (single file; parse it like .tool-versions)
- ${ASDF_CONFIG_FILE:-~/.asdfrc} parsing:
opt="$(
grep -E "^\\s*legacy_version_file\\s*=\\s*" "$config_path" |
head |
awk -F '=' '{print $2}' |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
[[ $opt == yes ]]
Stat caches:
- ${ASDF_CONFIG_FILE:-~/.asdfrc} => legacy_version_file (yes or no)
- ${ASDF_DATA_DIR:-~/.asdf}/plugins => list of plugins
- ${ASDF_DATA_DIR:-~/.asdf}/plugins/ruby/bin => list of relevant scripts
(list-legacy-filenames and parse-legacy-file)
- ${ASDF_DATA_DIR:-~/.asdf}/plugins/ruby/bin/list-legacy-filenames => list (or pattern made from it?)
- /foo/bar => { tool => version } (permanent cache via stat cache)
---
typeset -ga _p9k_asdf_meta_files=(
${ASDF_CONFIG_FILE:-~/.asdfrc}
${ASDF_DATA_DIR:-~/.asdf}/plugins
${ASDF_DATA_DIR:-~/.asdf}/plugins/*/bin{,/list-legacy-filenames,/parse-legacy-file}(N)
)
typeset -g _p9k_asdf_meta_sig # $ASDF_CONFIG_FILE ':' $ASDF_DATA_DIR ':' $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ':' $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ':' ${(j.:.)mtimes}
typeset -g _p9k_asdf_file_pat # example: '(.tool-versions|.ruby-version)'
typeset -gA _p9k_asdf_file_info # .ruby-version => ruby1 ('1' means parse-legacy-file is present)
- add _SHOW_SYSTEM to all *env segments.

View File

@ -4583,6 +4583,7 @@ function _p9k_asdf_init_meta() {
fi
local name
for name in $($list_names 2>/dev/null); do
[[ $name == (*/*|*:*|.tool-versions) ]] && continue
_p9k_asdf_file_info[$name]+="${plugin:t} $has_parse "
done
fi
@ -4608,71 +4609,32 @@ function _p9k_asdf_init_meta() {
}
}
function prompt_asdf() {
_p9k_asdf_check_meta || _p9k_asdf_init_meta || return
local -A versions
local plugin
for plugin in $_p9k_asdf_plugins; do
local var=ASDF_${(U)plugin//-/_}_VERSION
local val="${(P)var}"
[[ -n $val ]] && versions[$plugin]=$val
done
# Usage: _p9k_asdf_parse_version_file <file> <is_legacy>
#
# Mutates `versions` on success.
function _p9k_asdf_parse_version_file() {
local file=$1
local is_legacy=$2
local -a stat
zstat -A stat +mtime ~ 2>/dev/null || return
local dirs=($_p9k__parent_dirs ~)
local mtimes=($_p9k__parent_mtimes $stat[1])
local elem
for elem in ${(@)${:-{1..$#dirs}}/(#m)*/${${:-$MATCH:$_p9k__asdf_dir2files[$dirs[MATCH]]}#$MATCH:$mtimes[MATCH]:}}; do
if [[ $elem == *:* ]]; then
local dir=$dirs[${elem%%:*}]
zstat -A stat +mtime $dir 2>/dev/null || return
local files=($dir/.tool-versions(N) $dir/${(k)^_p9k_asdf_file_info}(N))
_p9k__asdf_dir2files[$dir]=$stat[1]:${(pj:\0:)files}
else
local files=(${(0)elem})
fi
local file
for file in $files; do
zstat -A stat +mtime $file 2>/dev/null || return
local cached=$_p9k_asdf_file2versions[$file]
zstat -A stat +mtime $file 2>/dev/null || return
if (( is_legacy )); then
local plugin has_parse
for plugin has_parse in $=_p9k_asdf_file_info[$file:t]; do
(( $+versions[$plugin] )) && continue
local cached=$_p9k_asdf_file2versions[$file:$plugin]
if [[ $cached == $stat[1]:* ]]; then
local file_versions=(${(0)${cached#*:}})
versions[$plugin]=${cached#*:}
else
local file_versions=()
if [[ $file == */.tool-versions ]]; then
{ local lines=(${(@)${(f)"$(<$file)"}/\#*}) } 2>/dev/null
local line
for line in $lines; do
local words=($=line)
(( $#words > 1 && $_p9k_asdf_plugins[(Ie)$words[1]] )) || continue
file_versions+=($words[1] "${words[2,-1]}")
done
if (( has_parse )); then
local v=($(${ASDF_DATA_DIR:-~/.asdf}/plugins/$plugin/bin/parse-legacy-file $file 2>/dev/null))
else
local plugin has_parse
for plugin has_parse in $=_p9k_asdf_file_info[$file:t]; do
if (( has_parse )); then
local v=($(${ASDF_DATA_DIR:-~/.asdf}/plugins/$plugin/bin/parse-legacy-file $file 2>/dev/null))
else
{ local v=($(<$file)) } 2>/dev/null
fi
(( $#v )) && file_versions+=($plugin "$v")
done
{ local v=($(<$file)) } 2>/dev/null
fi
_p9k_asdf_file2versions[$file]=$stat[1]:${(pj:\0:)file_versions}
(( $#v )) && versions[$plugin]="$v"
_p9k_asdf_file2versions[$file:$plugin]=$stat[1]:"$v"
fi
local plugin version
for plugin version in $file_versions; do
[[ -z $versions[$plugin] ]] && versions[$plugin]=$version
done
done
done
if [[ -r $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ]]; then
local file=$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
zstat -A stat +mtime $file 2>/dev/null || return
else
local cached=$_p9k_asdf_file2versions[$file]
if [[ $cached == $stat[1]:* ]]; then
local file_versions=(${(0)${cached#*:}})
@ -4689,13 +4651,110 @@ function prompt_asdf() {
fi
local plugin version
for plugin version in $file_versions; do
[[ -z $versions[$plugin] ]] && versions[$plugin]=$version
(( $+versions[$plugin] )) || versions[$plugin]=$version
done
fi
return 0
}
local plugin version
for plugin version in ${(kv)versions}; do
function prompt_asdf() {
_p9k_asdf_check_meta || _p9k_asdf_init_meta || return
local -A versions
local -a stat
zstat -A stat +mtime ~ 2>/dev/null || return
local dirs=($_p9k__parent_dirs ~)
local mtimes=($_p9k__parent_mtimes $stat[1])
local -i has_global
local elem
for elem in ${(@)${:-{1..$#dirs}}/(#m)*/${${:-$MATCH:$_p9k__asdf_dir2files[$dirs[MATCH]]}#$MATCH:$mtimes[MATCH]:}}; do
if [[ $elem == *:* ]]; then
local dir=$dirs[${elem%%:*}]
zstat -A stat +mtime $dir 2>/dev/null || return
local files=($dir/.tool-versions(N) $dir/${(k)^_p9k_asdf_file_info}(N))
_p9k__asdf_dir2files[$dir]=$stat[1]:${(pj:\0:)files}
else
local files=(${(0)elem})
fi
if [[ ${files[1]:h} == ~ ]]; then
has_global=1
local -A local_versions=(${(kv)versions})
versions=()
fi
local file
for file in $files; do
[[ $file == */.tool-versions ]]
_p9k_asdf_parse_version_file $file $? || return
done
done
if (( ! has_global )); then
has_global=1
local -A local_versions=(${(kv)versions})
versions=()
fi
if [[ -r $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ]]; then
_p9k_asdf_parse_version_file $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME 0 || return
fi
local plugin
for plugin in $_p9k_asdf_plugins; do
local upper=${(U)plugin//-/_}
local var=POWERLEVEL9K_ASDF_${upper}_SOURCES
if (( $+parameters[$var] )); then
local sources=(${(P)var})
else
var=POWERLEVEL9K_ASDF_SOURCES
if (( $+parameters[$var] )); then
local sources=(${(P)var})
else
local sources=(shell local global)
fi
fi
var=ASDF_${upper}_VERSION
local version="${(P)var}"
if [[ -n $version ]]; then
(( $sources[(I)shell] )) || continue
else
version=$local_versions[$plugin]
if [[ -n $version ]]; then
(( $sources[(I)local] )) || continue
else
version=$versions[$plugin]
[[ -n $version ]] || continue
(( $sources[(I)global] )) || continue
fi
fi
if [[ $version == $versions[$plugin] ]]; then
var=POWERLEVEL9K_ASDF_${upper}_PROMPT_ALWAYS_SHOW
if (( $+parameters[$var] )); then
[[ ${(P)var} == true ]] || continue
else
var=POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW
if (( $+parameters[$var] )); then
[[ ${(P)var} == true ]] || continue
else
continue
fi
fi
fi
if [[ $version == system ]]; then
var=POWERLEVEL9K_ASDF_${upper}_SHOW_SYSTEM
if (( $+parameters[$var] )); then
[[ ${(P)var} == true ]] || continue
else
var=POWERLEVEL9K_ASDF_SHOW_SYSTEM
if (( $+parameters[$var] )); then
[[ ${(P)var} == true ]] || continue
fi
fi
fi
_p9k_get_icon $0_$upper ${upper}_ICON $plugin
_p9k_prompt_segment $0_$upper green $_p9k_color1 $'\1'$_p9k_ret 0 '' ${version//\%/%%}
done
@ -6874,7 +6933,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit
fi
_p9k__param_pat=$'v38\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat=$'v39\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'