Improve zsh startup

This commit is contained in:
MangoPig
2026-06-01 16:59:04 +01:00
parent bec96e8456
commit 5b3f5e7698
3 changed files with 47 additions and 12 deletions

View File

@@ -8,6 +8,7 @@ zstyle ':vcs_info:git:*' formats ' %b'
typeset -g PROMPT_SHOW_SPACER=0
typeset -gA PROMPT_PROJECT_MATCH_CACHE
typeset -gA PROMPT_VERSION_CACHE
typeset -gA PROMPT_SEPARATOR_CACHE
typeset -g PROMPT_FIRST_RENDER=1
typeset -g PROMPT_PROJECT_ROOT_CACHE_PWD=''
typeset -g PROMPT_PROJECT_ROOT_CACHE=''
@@ -153,11 +154,17 @@ build_git_status_segment() {
build_prompt_separator_line() {
local last_status="$1"
local line_width="${COLUMNS:-80}"
local cache_key="${line_width}:${last_status}"
local separator_line=""
local color_prefix=""
local color_suffix=""
local i=0
if [[ -n ${PROMPT_SEPARATOR_CACHE[$cache_key]+x} ]]; then
print -r -- "${PROMPT_SEPARATOR_CACHE[$cache_key]}"
return 0
fi
if [ "$line_width" -lt 1 ]; then
line_width=1
fi
@@ -172,7 +179,8 @@ build_prompt_separator_line() {
((i++))
done
print -r -- "${color_prefix}${separator_line}${color_suffix}"
PROMPT_SEPARATOR_CACHE[$cache_key]="${color_prefix}${separator_line}${color_suffix}"
print -r -- "${PROMPT_SEPARATOR_CACHE[$cache_key]}"
}
build_prompt() {