diff --git a/tcshrc.prompt.final b/tcshrc.prompt.final index 1a4b385..43362e5 100644 --- a/tcshrc.prompt.final +++ b/tcshrc.prompt.final @@ -36,25 +36,29 @@ set prompt_segment_kinds=( \ prompt \ ) -foreach kind ( ${prompt_segment_kinds} ) - eval 'echo $?curr_'"${kind}"'_color' >& /dev/null - _debug "Eval of ${kind}" - if( $? == 0 ) then - eval "set curr_${kind}_color=impossible" - endif - eval 'set __new_this_color="${'"${kind}"'_color}"' - eval 'set __curr_this_color="${curr_'"${kind}"'_color}"' - if( "${__new_this_color}" != ${__curr_this_color} ) then +# The algorithm is duplicated with less branching to make startup a bit faster. +if ( ! $?cshenv_prompt_first_cache ) then + foreach kind ( ${prompt_segment_kinds} ) + eval 'set __new_this_color="${'"${kind}"'_color}"' 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 + end + set cshenv_prompt_first_cache=1 +else + foreach kind ( ${prompt_segment_kinds} ) + eval 'set __new_this_color="${'"${kind}"'_color}"' + eval 'set __curr_this_color="${curr_'"${kind}"'_color}"' + if( "${__new_this_color}" == "${__curr_this_color}" ) continue + + 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}"'"' + end +endif _debug "Done with color cacheing loop" - - _debug "Dynamic color loading processed..."