2020-06-20 11:11:09 +00:00
|
|
|
[ -r todo.txt ] || return
|
|
|
|
local -a stats
|
|
|
|
zstat -A stats +mtime -- todo.txt 2>/dev/null
|
|
|
|
if [ ! -v _cprompts_todo ] || [ $_cprompts_todo[4] -ne $stats[1] ]; then
|
2020-09-26 17:17:43 +00:00
|
|
|
local todofi=(${(f@)$(< todo.txt)})
|
2020-06-20 11:11:09 +00:00
|
|
|
local t_nf=0
|
|
|
|
local t_f=0
|
|
|
|
local colors=(red yellow green)
|
|
|
|
for i in $todofi; do
|
|
|
|
[ ${i:0:1} = "-" ] && ((t_nf++))
|
|
|
|
[ ${i:0:1} = "+" ] && ((t_f++))
|
|
|
|
done
|
|
|
|
local t_tot=$(($t_f+$t_nf))
|
|
|
|
[ $t_tot -gt 0 ] || return
|
|
|
|
typeset -g _cprompts_todo=($t_f $t_tot ${colors[$(( 1+int( $t_f / $t_tot.0 * 2 ) ))]} $stats[1])
|
|
|
|
fi
|
|
|
|
p10k segment -b ${_cprompts_todo[3]:-white} -i '' -t "${_cprompts_todo[1]:-unknown} / ${_cprompts_todo[2]:-unknown}"
|