diff options
Diffstat (limited to 'mac/.local/bin/task/taskwarrior-tui/increase-priority')
| -rwxr-xr-x | mac/.local/bin/task/taskwarrior-tui/increase-priority | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/mac/.local/bin/task/taskwarrior-tui/increase-priority b/mac/.local/bin/task/taskwarrior-tui/increase-priority new file mode 100755 index 0000000..26a3d53 --- /dev/null +++ b/mac/.local/bin/task/taskwarrior-tui/increase-priority @@ -0,0 +1,60 @@ +#!/bin/sh + +# The set -e option instructs the shell to immediately exit if any command has a non-zero exit status +# The set -u option treats unset variables (except for $* and $@) as an error +set -eu + +echo "Increase duration of task $*" + +# Fetch the duration value using taskwarrior and jq +dur=$(task "$@" export | jq -r '.[0].duration') + +# Check if the duration has hours +case "$dur" in +*H*) + # Extract both hour and minute parts + hour=$(echo "$dur" | awk -F 'T' '{split($2, a, "H"); print a[1]}') + minute=$(echo "$dur" | awk -F 'H' '{split($2, a, "M"); print a[1]}') + + # Add 30 to the minutes + new_minute=$((minute + 30)) + + # Check if minutes are 60 or more + if [ "$new_minute" -ge 60 ]; then + # Add 1 to the hour + new_hour=$((hour + 1)) + + # Calculate new minutes + new_minute=$((new_minute - 60)) + else + # Keep the original hour + new_hour=$hour + fi + + # Create the new duration string + new_dur="PT${new_hour}H${new_minute}M" + ;; +*) + # If duration is already 30M + if [ "$dur" = "PT30M" ]; then + # Make it 1H + new_dur="PT1H" + else + # Extract the minute part from the duration string + minute=$(echo "$dur" | awk -F 'T' '{split($2, a, "M"); print a[1]}') + + # Add 30 to the minutes + new_minute=$((minute + 30)) + + # Create the new duration string + new_dur="PT${new_minute}M" + fi + ;; +esac + +# Print the new duration +echo "Original duration: $dur" +echo "New duration: $new_dur" + +# Modify the task duration using taskwarrior +task rc.bulk=0 rc.confirmation=off rc.dependency.confirmation=off rc.recurrence.confirmation=off "$@" modify duration="$new_dur" |
