Add Powerlevel10k mise prompt configuration and source in zshrc

This commit is contained in:
Philip Henning 2025-08-21 08:29:41 +02:00
parent b479e0c0f7
commit 9498a31290
3 changed files with 51 additions and 0 deletions

View file

@ -143,6 +143,9 @@ dotfiles:
src: ssh/config
dst: ~/.ssh/config
chmod: '600'
f_p10k_mise:
dst: ~/.config/zsh/p10k.mise.zsh
src: config/zsh/p10k.mise.zsh
profiles:
meta_base:
variables:
@ -154,6 +157,7 @@ profiles:
- f_agenix_helper
- f_commonfunc
- f_config
- f_p10k_mise
- f_powerlevel10krc
- f_rmquarantine
- f_secretfiles

View file

@ -0,0 +1,46 @@
#
# {{@@ header() @@}}
#
# Powerlevel10k prompt segments for mise
# [Feature request: add segment for mise](https://github.com/romkatv/powerlevel10k/issues/2212)
# Source: https://github.com/2KAbhishek/dots2k/blob/main/config/zsh/prompt/p10k.mise.zsh
# Usage in ~/.zshrc:
# [[ -f ~/.config/zsh/p10k.mise.zsh ]] && source ~/.config/zsh/p10k.mise.zsh
() {
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
local parts=("${(@s/ /)plugin}")
local tool=${(U)parts[1]}
local version=${parts[2]}
p10k segment -r -i "${tool}_ICON" -s $tool -t "$version"
done
}
# Colors
typeset -g POWERLEVEL9K_MISE_BACKGROUND=1
typeset -g POWERLEVEL9K_MISE_DOTNET_CORE_BACKGROUND=93
typeset -g POWERLEVEL9K_MISE_ELIXIR_BACKGROUND=129
typeset -g POWERLEVEL9K_MISE_ERLANG_BACKGROUND=160
typeset -g POWERLEVEL9K_MISE_FLUTTER_BACKGROUND=33
typeset -g POWERLEVEL9K_MISE_GO_BACKGROUND=81
typeset -g POWERLEVEL9K_MISE_HASKELL_BACKGROUND=99
typeset -g POWERLEVEL9K_MISE_JAVA_BACKGROUND=196
typeset -g POWERLEVEL9K_MISE_JULIA_BACKGROUND=34
typeset -g POWERLEVEL9K_MISE_LUA_BACKGROUND=33
typeset -g POWERLEVEL9K_MISE_NODE_BACKGROUND=34
typeset -g POWERLEVEL9K_MISE_PERL_BACKGROUND=33
typeset -g POWERLEVEL9K_MISE_PHP_BACKGROUND=93
typeset -g POWERLEVEL9K_MISE_POSTGRES_BACKGROUND=33
typeset -g POWERLEVEL9K_MISE_PYTHON_BACKGROUND=33
typeset -g POWERLEVEL9K_MISE_RUBY_BACKGROUND=196
typeset -g POWERLEVEL9K_MISE_RUST_BACKGROUND=208
# Substitute the default asdf prompt element
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=("${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[@]/asdf/mise}")
}

View file

@ -11,6 +11,7 @@ fi
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f {{@@ env['HOME'] @@}}/.p10k.zsh ]] || source {{@@ env['HOME'] @@}}/.p10k.zsh
[[ -f {{@@ env['HOME'] @@}}/.config/zsh/p10k.mise.zsh ]] && source ~/.config/zsh/p10k.mise.zsh
# If you come from bash you might have to change your $PATH.
# export PATH=${HOME}/bin:/usr/local/bin:$PATH