update shell config

This commit is contained in:
2026-07-27 02:53:24 +02:00
parent 678cfb76ba
commit 21e902bd61
24 changed files with 300 additions and 634 deletions
+35 -7
View File
@@ -5,13 +5,42 @@ PROMPT='%F{blue}%n@%m%f %F{cyan}%~%f > '
if (( $+commands[starship] )); then
eval "$(starship init zsh)"
function uy_transient_prompt() {
local file palette color
file=${STARSHIP_CONFIG:-"$HOME/.config/starship.toml"}
palette=$(sed -n "s/^palette\s*=\s*'\(.*\)'/\1/p" "$file")
color=$(sed -n "/^\[palettes\.${palette}\]/,/^\[/{s/^accent\s*=\s*\"\(.*\)\"/\1/p}" "$file")
# accent of the [palettes.<name>] named by the top-level `palette` key.
function uy_starship_accent() {
setopt local_options extended_glob
local line palette in_palette=0
local -a lines
[[ -r $1 ]] || return 1
lines=( ${(f)"$(<$1)"} )
PROMPT="%F{$color}#%f " zle .reset-prompt
for line in $lines; do
if [[ $line == palette[[:blank:]]#=[[:blank:]]#\'*\' ]]; then
palette=${${line#*\'}%\'}
break
fi
done
[[ -n $palette ]] || return 1
for line in $lines; do
if (( in_palette )); then
[[ $line == \[* ]] && return 1
if [[ $line == accent[[:blank:]]#=[[:blank:]]#\"*\" ]]; then
REPLY=${${line#*\"}%\"}
return 0
fi
elif [[ $line == "[palettes.$palette]" ]]; then
in_palette=1
fi
done
return 1
}
function uy_transient_prompt() {
local REPLY
uy_starship_accent "${STARSHIP_CONFIG:-$HOME/.config/starship.toml}" &&
uy_accent=$REPLY
PROMPT="%F{${uy_accent:-blue}}#%f " zle .reset-prompt
}
autoload -Uz add-zle-hook-widget
@@ -21,4 +50,3 @@ if (( $+commands[starship] )); then
elif [[ -f "$HOME/.config/posh_theme.omp.json" ]] && (( $+commands[oh-my-posh] )); then
eval "$(oh-my-posh init zsh --config "$HOME/.config/posh_theme.omp.json")"
fi