From d980514bfffdcdba1ef057aadc1f9ff13c3e5449 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 31 Dec 2025 12:33:50 -0700 Subject: [PATCH] Add Create Interactive Picker For Set Of Subtasks as a Taskfile TIL --- README.md | 3 +- ...-interactive-picker-for-set-of-subtasks.md | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 taskfile/create-interactive-picker-for-set-of-subtasks.md diff --git a/README.md b/README.md index e8f116b..eaff228 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1714 TILs and counting..._ +_1715 TILs and counting..._ See some of the other learning resources I work on: @@ -1534,6 +1534,7 @@ If you've learned something here, support my efforts writing daily TILs by ### Taskfile +- [Create Interactive Picker For Set Of Subtasks](taskfile/create-interactive-picker-for-set-of-subtasks.md) - [Run A Task If It Meets Criteria](taskfile/run-a-task-if-it-meets-criteria.md) ### tmux diff --git a/taskfile/create-interactive-picker-for-set-of-subtasks.md b/taskfile/create-interactive-picker-for-set-of-subtasks.md new file mode 100644 index 0000000..2996a31 --- /dev/null +++ b/taskfile/create-interactive-picker-for-set-of-subtasks.md @@ -0,0 +1,74 @@ +# Create Interactive Picker For Set Of Subtasks + +For [my TIL repo](https://github.com/jbranchaud/til), I have a `Taskfile.yml` +that defines a set of `notes:*` tasks for interacting with a `NOTES.md` file +that lives in a private Git submodule. + +I wanted to make it easier on myself to not have to remember all the different +`notes` subtasks, so I created a helper task to make it easy to see the options +and run one. + +A summary of the Taskfile is shown below including the entirety of the `notes` +task. That task will parse a listing of the available tasks (via `task --list` +and some `sed` commands) and pass those to `fzf` to provide an interactive +picker of the available subtasks. + +```yaml +tasks: + notes: + desc: Interactive picker for notes tasks + cmds: + - | + TASK=$(task --list | grep "^\* notes:" | sed 's/^\* notes://' | sed 's/\s\+/ - /' | fzf --prompt="Select notes task: " --height=40% --reverse) || true + if [ -n "$TASK" ]; then + TASK_NAME=$(echo "$TASK" | awk '{print $1}' | sed 's/:$//') + task notes:$TASK_NAME + fi + interactive: true + silent: true + + notes:edit: + ... + + notes:sync: + ... + + notes:open: + ... + + notes:push: + ... + + notes:status: + ... + + notes:pull: + ... + + notes:diff: + ... + + notes:log: + ... +``` + +Now I can run the `notes` task to get a summary and interactive picker that +looks like the following: + +```sh +❯ task notes +Select notes task: + 9/9 +> │ Interactive picker for notes tasks + diff: Show uncommitted changes in notes + edit: All-in-one edit, commit, and push notes + log: Show recent commit history for notes + open: Opens NOTES.md (syncs latest changes first) in default editor + pull: Pull latest changes (alias for sync) + push: Commit and push changes to notes submodule + status: Check status of notes submodule + sync: Sync latest changes from the notes submodule +``` + +It pulls in the subtask name and description. I can then use `fzf`'s navigation +and filtering to narrow down and select the task I want to run.