~tardypad/dotfiles

ref: 52edb52002d004d9fdc50737a5ed70202c75b268 dotfiles/files/scripts/shell/pick-task -rwxr-xr-x 1.3 KiB
52edb520 — Damien Tardy-Panis Rename task and time-tracker description to comment 3 months ago
                                                                                
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

TASK=$(
  task -n ids \
    | fzf --reverse \
          --no-multi \
          --info hidden \
          --header "$( printf '\n' )" \
          --prompt 'pick task ' \
    | tail -n1
)

[ -n "${TASK}" ] || exit

TASK_ID="$( echo "${TASK}" | cut -f1 )"
TASK_NAME="$( echo "${TASK}" | cut -f2 )"

printf 'Id: %s\n' "${TASK_ID}"

if [ -n "${TASK_NAME}" ]; then
  printf 'Name: %s\n' "${TASK_NAME}"
fi

printf '\n'
while true; do
  printf 'Pomodoro duration (min): '
  read -r POMODORO_DURATION

  case "${POMODORO_DURATION}" in
    *[!0-9]*)
      echo 'duration must be an integer' >&2
      continue
      ;;
  esac

  break
done

printf '\n'
printf 'Log [y/N]: '
read -r LOG

TASK_COMMENT=
if [ "${LOG}" = 'Y' ] || [ "${LOG}" = 'y' ]; then
    printf 'Comment: '
    read -r TASK_COMMENT
fi

printf '\n'
printf 'Do not disturb [y/N]: '
read -r DO_NOT_DISTURB

if [ "${LOG}" = 'Y' ] || [ "${LOG}" = 'y' ]; then
  task -l pick "${TASK_ID}" "${TASK_COMMENT}"
else
  task pick "${TASK_ID}" "${TASK_COMMENT}"
fi

if [ -n "${POMODORO_DURATION}" ]; then
  nohup \
    pomodoro start "${POMODORO_DURATION}" \
    > /dev/null 2>&1
fi

if [ "${DO_NOT_DISTURB}" = 'Y' ] || [ "${DO_NOT_DISTURB}" = 'y' ]; then
  nohup \
    do-not-disturb -d "${POMODORO_DURATION}" -w "${TASK_ID}" enable \
    > /dev/null 2>&1
fi