From e28a87f6690c9ba87eec9542095b270cdc16f503 Mon Sep 17 00:00:00 2001 From: shokinn Date: Wed, 17 Jun 2026 09:51:04 +0200 Subject: [PATCH 1/3] Refactor prompt_mise function for improved plugin handling and zsh-identifier safety [Created using GitHub Copilot] Co-authored-by: Copilot --- dotfiles/config/zsh/p10k.mise.zsh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/dotfiles/config/zsh/p10k.mise.zsh b/dotfiles/config/zsh/p10k.mise.zsh index b1b68b0..57a8f46 100644 --- a/dotfiles/config/zsh/p10k.mise.zsh +++ b/dotfiles/config/zsh/p10k.mise.zsh @@ -12,11 +12,20 @@ function prompt_mise() { local plugins=("${(@f)$(mise ls --current --offline 2>/dev/null | awk '!/\(symlink\)/ && $3!="~/.tool-versions" && $3!="~/.config/mise/config.toml" && $3!="(missing)" {if ($1) print $1, $2}')}") local plugin - for plugin in ${(k)plugins}; do + + for plugin in "${plugins[@]}"; do local parts=("${(@s/ /)plugin}") - local tool=${(U)parts[1]} - local version=${parts[2]} - p10k segment -r -i "${tool}_ICON" -s $tool -t "$version" + local tool_raw="${parts[1]}" + local version="${parts[2]}" + + [[ -z "$tool_raw" || -z "$version" ]] && continue + + # P10k segment state/icon names must be zsh-identifier-safe. + # Example: aqua:raviqqe/muffet -> AQUA_RAVIQQE_MUFFET + local tool="${(U)tool_raw}" + tool="${tool//[^A-Z0-9_]/_}" + + p10k segment -r -i "${tool}_ICON" -s "$tool" -t "$version" done } @@ -39,8 +48,8 @@ typeset -g POWERLEVEL9K_MISE_PYTHON_BACKGROUND=33 typeset -g POWERLEVEL9K_MISE_RUBY_BACKGROUND=196 typeset -g POWERLEVEL9K_MISE_RUST_BACKGROUND=208 + typeset -g POWERLEVEL9K_MISE_AQUA_RAVIQQE_MUFFET_BACKGROUND=33 # Substitute the default asdf prompt element typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=("${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]/asdf/mise}") } - From f0ec74ec6fe05bbddb5f9ee24c9559408e4b8763 Mon Sep 17 00:00:00 2001 From: shokinn Date: Wed, 17 Jun 2026 10:12:40 +0200 Subject: [PATCH 2/3] Display the tool name, when an icon does not exist --- dotfiles/config/zsh/p10k.mise.zsh | 38 ++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/dotfiles/config/zsh/p10k.mise.zsh b/dotfiles/config/zsh/p10k.mise.zsh index 57a8f46..746b255 100644 --- a/dotfiles/config/zsh/p10k.mise.zsh +++ b/dotfiles/config/zsh/p10k.mise.zsh @@ -9,6 +9,38 @@ # [[ -f ~/.config/zsh/p10k.mise.zsh ]] && source ~/.config/zsh/p10k.mise.zsh () { + function _prompt_mise_has_visual_identifier() { + local tool="$1" + local icon_name="${tool}_ICON" + local icon_override="POWERLEVEL9K_${icon_name}" + local state_visual_identifier="POWERLEVEL9K_MISE_${tool}_VISUAL_IDENTIFIER_EXPANSION" + local segment_visual_identifier="POWERLEVEL9K_MISE_VISUAL_IDENTIFIER_EXPANSION" + local parameter value + + for parameter in "$state_visual_identifier" "$segment_visual_identifier" "$icon_override"; do + if (( ${+parameters[$parameter]} )); then + value="${(P)parameter}" + [[ -n "$value" ]] && return 0 + return 1 + fi + done + + if (( ${+functions[print_icon]} )); then + [[ -n "$(print_icon "$icon_name")" ]] && return 0 + elif (( ${+functions[_p9k_init_icons]} )); then + _p9k_init_icons + (( ${+icons[$icon_name]} )) && [[ -n "${icons[$icon_name]}" ]] && return 0 + fi + + return 1 + } + + function _prompt_mise_fallback_label() { + local label="${1:t}" + label="${label##*:}" + print -r -- "${label:-$1}" + } + function prompt_mise() { local plugins=("${(@f)$(mise ls --current --offline 2>/dev/null | awk '!/\(symlink\)/ && $3!="~/.tool-versions" && $3!="~/.config/mise/config.toml" && $3!="(missing)" {if ($1) print $1, $2}')}") local plugin @@ -25,7 +57,11 @@ local tool="${(U)tool_raw}" tool="${tool//[^A-Z0-9_]/_}" - p10k segment -r -i "${tool}_ICON" -s "$tool" -t "$version" + if _prompt_mise_has_visual_identifier "$tool"; then + p10k segment -r -i "${tool}_ICON" -s "$tool" -t "$version" + else + p10k segment -r -s "$tool" -t "$(_prompt_mise_fallback_label "$tool_raw") $version" + fi done } From cd0d3fda4dc3a98dc4a30b2a8c9a421c013857b5 Mon Sep 17 00:00:00 2001 From: shokinn Date: Wed, 17 Jun 2026 10:26:17 +0200 Subject: [PATCH 3/3] Fix segment display order in prompt_mise function --- dotfiles/config/zsh/p10k.mise.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/config/zsh/p10k.mise.zsh b/dotfiles/config/zsh/p10k.mise.zsh index 746b255..c18765e 100644 --- a/dotfiles/config/zsh/p10k.mise.zsh +++ b/dotfiles/config/zsh/p10k.mise.zsh @@ -60,7 +60,7 @@ if _prompt_mise_has_visual_identifier "$tool"; then p10k segment -r -i "${tool}_ICON" -s "$tool" -t "$version" else - p10k segment -r -s "$tool" -t "$(_prompt_mise_fallback_label "$tool_raw") $version" + p10k segment -r -s "$tool" -t "$version $(_prompt_mise_fallback_label "$tool_raw")" fi done }