Skip to content

Instantly share code, notes, and snippets.

@linuxcaffe
Forked from wbsch/on-launch_stopstarted.sh
Created June 1, 2019 23:19
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 linuxcaffe/60a773e359d46090d2da78ca7198f709 to your computer and use it in GitHub Desktop.
Save linuxcaffe/60a773e359d46090d2da78ca7198f709 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