ZSHFiles/custom/segments/prompt_c_todo

18 lines
639 B
Plaintext
Raw Normal View History

[ -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
local todofi=(${(f@)${mapfile[todo.txt]}})
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}"