]> git.rmz.io Git - dotfiles.git/commitdiff
zsh: add a count of todays taskwarrior tasks to prompt
authorSamir Benmendil <me@rmz.io>
Mon, 27 Jan 2025 20:46:16 +0000 (20:46 +0000)
committerSamir Benmendil <me@rmz.io>
Mon, 27 Jan 2025 20:47:20 +0000 (20:47 +0000)
zsh/lib/prompt.zsh

index f6a8dafe424b03e9cd79ba32411387c613052524..3ca62a41b4dd5b02c118e7720b64e9fc497eb7e5 100644 (file)
@@ -6,7 +6,7 @@ hostcolor=cyan
 [[ $(hostname) == "tardis" ]]  && hostcolor=red
 
 precmd() {
-  PROMPT=$'%T %n@%{$fg[$hostcolor]%}%m$(jobs_prompt)%-0>..>$(git_prompt_status)%>>\n'
+  PROMPT=$'%T $(task_today_list)%n@%{$fg[$hostcolor]%}%m$(jobs_prompt)%-0>..>$(git_prompt_status)%>>\n'
   PROMPT+=$'$(virtualenv_prompt)%(?..%{$fg_bold[white]%}%?)%{$reset_color%}$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} '
   RPROMPT='%{$fg[green]%}%~%{$reset_color%}'
 }
@@ -135,3 +135,13 @@ function print_if_fits() {
   length=${#${(S%%)1//$~zero/}}
   echo "%-$length(l.$1.)"
 }
+
+function task_today_list() {
+  local task_cmd=(task rc.verbose:nothing)
+  local task_count=$($task_cmd $($task_cmd _get rc.report.today.filter) count)
+
+  local task_status=""
+  task_status+="%{$fg_bold[red]%} $task_count "
+  task_status+="%{$reset_color%}"
+  echo $task_status
+}