Skip to content

Instantly share code, notes, and snippets.

@wbsch
Last active June 1, 2019 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wbsch/07edbf4b1393b1608613 to your computer and use it in GitHub Desktop.
Save wbsch/07edbf4b1393b1608613 to your computer and use it in GitHub Desktop.
Taskwarrior hook that stops all active tasks when "task FILTER start" is run. PoC for https://bug.tasktools.org/browse/TW-1712
#!/usr/bin/env bash
# Stops all previously active tasks on "task FILTER start"
#
# Only pending tasks are checked/stopped. If you really want to stop
# started tasks that are completed/deleted, remove the status:pending
# filter. Note that this will decrease performance, and should not
# be necessary.
tw_command=""
for i in "$@"; do
if [ "${i:0:8}" == "command:" ]; then
tw_command="${i:8}"
break
fi
done
if [ "$tw_command" == "start" ]; then
for t in $(task status:pending +ACTIVE _uuids); do
task $t stop
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment