Dynamic prompt colors cacheing loop

This commit is contained in:
2026-06-23 19:10:18 -04:00
parent 9af1431df8
commit 746b839965
+35 -123
View File
@@ -14,134 +14,46 @@
_debug "Setting up dynamic colour loading..." _debug "Setting up dynamic colour loading..."
# Recompute cached sgr codes from any configuration updates # Recompute cached sgr codes from any configuration updates
if( ! $?curr_branch_color ) then set prompt_segment_kinds=( \
set curr_branch_color=impossible branch \
endif dirs \
if( "${curr_branch_color}" != "${branch_color}" ) then ahead_tracking \
set curr_branch_color="${branch_color}" behind_tracking \
set branch_color_seq="%{[`__build_sgr_code no-csi reset ${curr_branch_color}`m" percent \
endif at \
depth \
line \
path \
host \
date \
time \
text \
brace \
user \
prompt \
)
if( ! $?curr_dirs_color ) then foreach kind ( ${prompt_segment_kinds} )
set curr_dirs_color=impossible eval 'echo $?curr_'"${kind}"'_color' >& /dev/null
endif _debug "Eval of ${kind}"
if( "${curr_dirs_color}" != "${dirs_color}" ) then if( $? == 0 ) then
set curr_dirs_color="${dirs_color}" eval "set curr_${kind}_color=impossible"
set dirs_color_seq="%{[`__build_sgr_code no-csi reset ${curr_dirs_color}`m" endif
endif eval 'set __new_this_color="${'"${kind}"'_color}"'
eval 'set __curr_this_color="${curr_'"${kind}"'_color}"'
if( "${__new_this_color}" != ${__curr_this_color} ) then
eval 'set curr_'"${kind}"'_color="'${__new_this_color}'"'
set __this_color_seq="%{[`__build_sgr_code no-csi reset ${__new_this_color}`m%}"
eval 'set '"${kind}"'_color_seq="'"${__this_color_seq}"'"'
endif
end
if( ! $?curr_ahead_tracking_color ) then _debug "Done with color cacheing loop"
set curr_ahead_tracking_color=impossible
endif
if( "${curr_ahead_tracking_color}" != "${ahead_tracking_color}" ) then
set curr_ahead_tracking_color="${ahead_tracking_color}"
set ahead_tracking_color_seq="^[[`__build_sgr_code no-csi reset ${curr_ahead_tracking_color}`m"
endif
if( ! $?curr_behind_tracking_color ) then
set curr_behind_tracking_color=impossible
endif
if( "${curr_behind_tracking_color}" != "${behind_tracking_color}" ) then
set curr_behind_tracking_color="${behind_tracking_color}"
set behind_tracking_color_seq="^[[`__build_sgr_code no-csi reset ${curr_behind_tracking_color}`m"
endif
if( ! $?curr_percent_color ) then
set curr_percent_color=impossible
endif
if( "${curr_percent_color}" != "${percent_color}" ) then
set curr_percent_color="${percent_color}"
set percent_color_seq="[`__build_sgr_code no-csi reset ${curr_percent_color}`m"
endif
if( ! $?curr_at_color ) then
set curr_at_color=impossible
endif
if( "${curr_at_color}" != "${at_color}" ) then
set curr_at_color="${at_color}"
set at_color_seq="%{[`__build_sgr_code no-csi reset ${curr_at_color}`m%}"
endif
if( ! $?curr_depth_color ) then
set curr_depth_color=impossible
endif
if( "${curr_depth_color}" != "${depth_color}" ) then
set curr_depth_color="${depth_color}"
set depth_color_seq="%{[`__build_sgr_code no-csi reset ${curr_depth_color}`m%}"
endif
if( ! $?curr_line_color ) then
set curr_line_color=impossible
endif
if( "${curr_line_color}" != "${line_color}" ) then
set curr_line_color="${line_color}"
set line_color_seq="%{[`__build_sgr_code no-csi reset ${curr_line_color}`m%}"
endif
if( ! $?curr_path_color ) then
set curr_path_color=impossible
endif
if( "${curr_path_color}" != "${path_color}" ) then
set curr_path_color="${path_color}"
set path_color_seq="%{[`__build_sgr_code no-csi reset ${curr_path_color}`m%}"
endif
if( ! $?curr_host_color ) then
set curr_host_color=impossible
endif
if( "${curr_host_color}" != "${host_color}" ) then
set curr_host_color="${host_color}"
set host_color_seq="%{[`__build_sgr_code no-csi reset ${curr_host_color}`m%}"
endif
if( ! $?curr_date_color ) then
set curr_date_color=impossible
endif
if( "${curr_date_color}" != "${date_color}" ) then
set curr_date_color="${date_color}"
set date_color_seq="[`__build_sgr_code no-csi reset ${curr_date_color}`m"
endif
if( ! $?curr_time_color ) then
set curr_time_color=impossible
endif
if( "${curr_time_color}" != "${time_color}" ) then
set curr_time_color="${time_color}"
set time_color_seq="[`__build_sgr_code no-csi reset ${curr_time_color}`m"
endif
if( ! $?curr_text_color ) then
set curr_text_color=impossible
endif
if( "${curr_text_color}" != "${text_color}" ) then
set curr_text_color="${text_color}"
set text_color_seq="[`__build_sgr_code no-csi reset ${curr_text_color}`m"
endif
if( ! $?curr_brace_color ) then
set curr_brace_color=impossible
endif
if( "${curr_brace_color}" != "${brace_color}" ) then
set curr_brace_color="${brace_color}"
set brace_color_seq="%{[`__build_sgr_code no-csi reset ${curr_brace_color}`m%}"
endif
if( ! $?curr_user_color ) then
set curr_user_color=impossible
endif
if( "${curr_user_color}" != "${user_color}" ) then
set curr_user_color="${user_color}"
set user_color_seq="%{[`__build_sgr_code no-csi reset ${curr_user_color}`m%}"
endif
if( ! $?curr_prompt_color ) then
set curr_prompt_color=impossible
endif
if( "${curr_prompt_color}" != "${prompt_color}" ) then
set curr_prompt_color="${prompt_color}"
set prompt_color_seq="%{[`__build_sgr_code no-csi reset ${curr_prompt_color}`m%}"
endif
_debug "Dynamic color loading processed..." _debug "Dynamic color loading processed..."