From cf01e98ef086fc6fe2aa373d4e9609f55a8ed72a Mon Sep 17 00:00:00 2001
From: romkatv <roman.perepelitsa@gmail.com>
Date: Mon, 21 Oct 2019 21:31:44 +0200
Subject: define P9K_TODO_FILTERED_TASK_COUNT and P9K_TODO_TOTAL_TASK_COUNT

These new parameters can be used to customize the content of `todo` prompt.

Example:

    POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT / $P9K_TODO_TOTAL_TASK_COUNT'

The default format is '$P9K_TODO_TOTAL_TASK_COUNT', just like before.

Fixes #283.
---
 internal/p10k.zsh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'internal')

diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 1461936a..7b8ebbe1 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -2373,18 +2373,21 @@ instant_prompt_date() {
 ################################################################
 # todo.sh: shows the number of tasks in your todo.sh file
 prompt_todo() {
+  unset P9K_TODO_TOTAL_TASK_COUNT P9K_TODO_FILTERED_TASK_COUNT
   local todo=$commands[todo.sh]
   [[ -n $todo && -r $_p9k_todo_file ]] || return
   if ! _p9k_cache_stat_get $0 $_p9k_todo_file; then
     local count="$($todo -p ls | tail -1)"
-    if [[ $count == (#b)'TODO: '[[:digit:]]##' of '([[:digit:]]##)' '* ]]; then
-      _p9k_cache_stat_set 1 $match[1]
+    if [[ $count == (#b)'TODO: '([[:digit:]]##)' of '([[:digit:]]##)' '* ]]; then
+      _p9k_cache_stat_set 1 $match[1] $match[2]
     else
-      _p9k_cache_stat_set 0 0
+      _p9k_cache_stat_set 0
     fi
   fi
   (( $_p9k_cache_val[1] )) || return
-  _p9k_prompt_segment "$0" "grey50" "$_p9k_color1" 'TODO_ICON' 0 '' "${_p9k_cache_val[2]}"
+  typeset -gi P9K_TODO_FILTERED_TASK_COUNT=$_p9k_cache_val[2]
+  typeset -gi P9K_TODO_TOTAL_TASK_COUNT=$_p9k_cache_val[3]
+  _p9k_prompt_segment "$0" "grey50" "$_p9k_color1" 'TODO_ICON' 0 '' "$P9K_TODO_TOTAL_TASK_COUNT"
 }
 
 ################################################################
-- 
cgit v1.2.3