summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-28 16:34:51 +0200
committerPaul Buetow <paul@buetow.org>2026-02-28 16:34:51 +0200
commitd99d053a3fcf595c1e5b7008e3d49b38bb2c2e7a (patch)
treeaa2ed56d66addce52c3ed61a82d2a2645157a7a1
parent91408864bd47e24daf6f0ba089d0e3c159a78607 (diff)
Update
-rw-r--r--fish/conf.d/taskwarrior.fish23
1 files changed, 17 insertions, 6 deletions
diff --git a/fish/conf.d/taskwarrior.fish b/fish/conf.d/taskwarrior.fish
index ba71cbf..c63865a 100644
--- a/fish/conf.d/taskwarrior.fish
+++ b/fish/conf.d/taskwarrior.fish
@@ -236,6 +236,18 @@ function taskwarrior::quicklogger
end
end
+# Parses a random-quote entry. If it matches "word: description", echoes project then description (one per line); otherwise echoes empty then entry.
+function _taskwarrior::random_quote_parse_entry
+ set -l entry "$argv[1]"
+ if string match -q -r '^[^:]+: .+' -- $entry
+ echo (string lower -- (string trim -- (string replace -r '^([^:]+): (.+)$' '$1' -- $entry)))
+ echo (string replace -r '^([^:]+): (.+)$' '$2' -- $entry)
+ else
+ echo ""
+ echo $entry
+ end
+end
+
# Fills available +random task slots by picking random bullet-point entries from
# random .md files in the notes/random directory. Each slot gets one entry chosen
# by selecting a random file and then a random "* "-prefixed line within it.
@@ -276,12 +288,11 @@ function taskwarrior::random_quote
# Pick one entry at random and tag it with both +random and the source file tag
set -l entry $entries[(builtin random 1 (count $entries))]
-
- # 10% chance to also tag the task as +work (1-in-10 roll)
- set -l extra_tags
- test (builtin random 1 10) -eq 1; and set extra_tags --tag work
-
- _taskwarrior::add_task --tag random --tag $file_tag $extra_tags $entry
+ set -l parsed (_taskwarrior::random_quote_parse_entry $entry)
+ set -l add_args --tag random --tag $file_tag
+ test -n "$parsed[1]"; and set -a add_args --project $parsed[1]
+ test (builtin random 1 10) -eq 1; and set -a add_args --tag work
+ _taskwarrior::add_task $add_args $parsed[2]
end
end