Merge branch 'master' into sysadmin-master
* master: Move battery thresholds to static defs. Uncouple the "impossible" branch of changed colors.
This commit is contained in:
@@ -147,6 +147,14 @@ set host_prompt="${CSHENV_HOSTNAME}"
|
||||
set path_prompt="%c02"
|
||||
set end_prompt="%#"
|
||||
|
||||
# The battery level thresholds are fixed, no need to recompute each prompt.
|
||||
set critical_battery_level = 10
|
||||
set low_battery_level = 20
|
||||
set weak_battery_level = 33
|
||||
set medium_battery_level = 50
|
||||
set strong_battery_level = 75
|
||||
|
||||
|
||||
alias oldp 'set prompt="$prompt_simple"; set cshenv_user_prompt_override'
|
||||
alias newp 'set prompt="$prompt_cool"; unset cshenv_user_prompt_override'
|
||||
|
||||
|
||||
+17
-19
@@ -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..."
|
||||
|
||||
|
||||
@@ -69,12 +73,6 @@ endif
|
||||
@ prompt_hcolor = $prompt_hcolor % ${#reference_colors}
|
||||
@ prompt_hsym = $prompt_hsym % ${#referencechars}
|
||||
|
||||
set critical_battery_level = 10
|
||||
set low_battery_level = 20
|
||||
set weak_battery_level = 33
|
||||
set medium_battery_level = 50
|
||||
set strong_battery_level = 75
|
||||
|
||||
|
||||
while( ${prompt_hcolor} == 0 )
|
||||
_debug colorshuffle
|
||||
|
||||
Reference in New Issue
Block a user