Skip to content

Instantly share code, notes, and snippets.

@shirobachi
Last active March 5, 2023 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirobachi/462afc1a03b6e5038018e0f989b39175 to your computer and use it in GitHub Desktop.
Save shirobachi/462afc1a03b6e5038018e0f989b39175 to your computer and use it in GitHub Desktop.
taskwarrior subtask

taskwarrior subtask

This is simple script for making subtasks in taskwarrior. Very useful if use taskwarrior-tui.

Installation

Autoupdate

[[ ! -f /tmp/task-subtasks.sh ]] && curl -s https://gist.githubusercontent.com/SimonHryszko/462afc1a03b6e5038018e0f989b39175/raw/68e33386d00d90007c8f780da9cc227f22a4957f/task-subtasks.sh -o /tmp/task-subtasks.sh; chmod +x /tmp/task-subtasks.sh

Manual

  1. Download script to location of your choice
  2. Make it executable chmod +x task-subtasks.sh

Integration with taskwarrior-tui

Automatic

echo 'uda.taskwarrior-tui.shortcuts.2=/tmp/task-subtasks.sh' >> "$HOME/.taskrc"

Manual

Add to your ~/.taskrc:

uda.taskwarrior-tui.shortcuts.2=/path/to/task-subtasks.sh

2 is the shortcut number. You can use any number you want.

Usage

  1. Select task in taskwarrior-tui
  2. Press 2 (or any other number you choose)
  3. Enter subtask name
  4. Press Enter
  5. Repeat steps 3-4 to add more subtasks
  6. Press ^D (Ctrl+D) to finish

Problems

If you have any problems, please comment this gist.
If you like it, you can buy me a coffee :)

#!/bin/bash
echo "You adding subtask to following task:"
task _get "$1.description"
echo -e "Finish with ^D(Ctrl+D)\n\n"
while read -r line; do
if task add "$line"; then
ID=$(task _ids "$line" | sort | tail -1)
task "$1" modify depends:"$ID"
else
echo "Failed to add task: $line"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment