summaryrefslogtreecommitdiff
path: root/mac/.local/bin/task/taskwarrior-tui/cycle-priority
blob: 43bc91edb1a256ca4ca1abb090c7ddd62ff11e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh

uuid="$1"

# Get the current priority of the task
current_priority=$(task _get $uuid.priority)

# Cycle through the priorities: H -> M -> L -> (unset) -> H
case "$current_priority" in
H)
  new_priority="M"
  echo "Switching priority from 'H' to 'M'"
  ;;
M)
  new_priority="L"
  echo "Switching priority from 'M' to 'L'"
  ;;
L)
  new_priority=""
  echo "Switching priority from 'L' to (no priority)"
  ;;
"")
  new_priority="H"
  echo "Switching priority from (no priority) to 'H'"
  ;;
esac

# Update the task with the new priority value, or remove priority if it's an empty string
if [ -n "$new_priority" ]; then
  echo "Updating task $uuid with new priority: $new_priority"
  task rc.bulk=0 rc.confirmation=off "$uuid" modify priority="$new_priority"
else
  echo "Removing priority from task $uuid"
  task rc.bulk=0 rc.confirmation=off "$uuid" modify priority:
fi