DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Task Management and Time Tracking


Taskwarrior

Install with apt install taskwarrior on Ubuntu. Add taskwarrior in oh-my-zsh plugin list, run task <TAB> and you will see tasks and commands list.

All data of taskwarrior is saved in folder ~/.task by default, which can be modified by data.location=~/.task in ~/.taskrc.

The tasks are saved as plain texts in xxx.data files in this folder.

Configurations

Add the following to ~/.taskrc:

dateformat=y.m.d-h:n
weekstart=monday
editor=nvim

So you can specify 2020-05-13 12:23:00 as 20.5.13-12:23. Set the first day of a week as Monday instead of Sunday (default value).

Note 1: If you set dateformat as y.m.d h:n, it is prettier when printed. But when defining a date, you have to quote it, say, '20.5.13 12:23' to avoid the space between date and time interpreted by the shell. So it's more convenient to use a dash instead of a space as separator.

Note 2: editor is only used in edit command.

Note 3: You can test the effect of any configurations with task cmd rc.<key>:val instead of run task config key val, or adding key=val in ~/.taskrc. After it meets your expectation, persist it with task config command.

Useful operations

task add "task description" +tag1 +tag2 project:projName priority:H
task 3 start
task 3 in        # print details of task #3, `in` is abbreviation for `information`
task projects    # list all projects
task tags        # list all tags
task             # list all tasks
task list
task waiting     # list all waiting tasks
task overdue     # 列出所有超过截至期限但仍未完成的任务
task scheduled   # list all tasks scheduled, but not ready
# the *Active* attribute of a *started* task show how long this task
# have been started, while that attribute of a *not-start-yet* task is blank.

task +tag1 list  # list tasks with tag1
task project:Books list  # list all tasks in project "Books"
task 3 done      # finish task #3
task 2 delete
task 5 info   # show task creation time, etc
task 3 modify +tag3   # add tag3 to task #3
task completed  # list completed tasks
task calendar   # show calendar of all tasks
task burndown   # show burndown graph
task show       # list all configurations
task 3 modify wait:6m   # postpone/cancel task #3

Here the numbers (3, 2, 5, etc) is the ID from task list.

wait:6m makes this task appear after 6 months, when it is invalid in most cases. List these tasks with task waiting.

H, M and L represent High, Medium, Low. The L value is considered a higher priority than no priority.

Projects

Using a project hierarchy:

$ task add project:Home.Kitchen Clean the floor
$ task add project:Home.Kitchen Replace broken light bulb
$ task add project:Home.Garden Plant the bulbs

$ task project:Home.Kitchen count
2

$ task project:Home.Garden count
1

$ task project:Home count
3

List all tasks in a project:

task add '完成 csvsql 对应的命令行实现' due:tomorrow project:Books.Terminal
task project:Books list

Task backup and restore

task export > backup.json
task import backup.json

Color theme

If you don't like the default color theme dark-256.theme (while I think this is OK), uncomment one of line include ... theme in ~/.taskrc.

Date and time

Time unit X: X denotes a time unit, which could be:

  • s: second
  • min: minute
  • h: hour
  • d (day),
  • w (week),
  • m (month),
  • y (year)

Set the due date with due:<timePoint>, where can be:

  • today, tomorrow, yesterday, now
  • eoX: end of current X
  • soX: start of next X
  • day of week: mon, tue, wes, thr, fri, sat, sun
  • month of year: jan, feb, mar, ...
  • durations: nX, where n is a number. For example: 30min means now+30 minutes. So as to 5d, 2m, 3w, 1y.
  • sum/difference of durations: 1w+3d means 10 days from now on, while 1w-2d means 5 days from now on.

除了任务结束时间,还有以下几个时间点可以设置:

  • scheduled: 任务计划开始时间,scheduled:<timePoint>, 如果一个 task 的 scheduled 时间早于当前时间,则状态变为 ready, 如果没有设置 scheduled 时间,则始终为 ready 状态, 用 task ready 列出所有处于 ready 状态的任务;

  • start: 任务实际开始时间,使用 start 命令开始一个任务,task 3 start, 一个被 start 的 task 状态变为 active,具备高 urgency, 用 task active 列出处于 active 状态的任务。

  • wait: 只有当前时间晚于任务的 wait 时间,此任务才会出现在任务列表中, 用于避免当前不关心的任务出现在任务列表中,用 task waiting 列出这些任务;

  • until: 超过这个时间节点后,如果任务仍然没有开始执行,则会被自动删除;

综合示例

task add Send Alice a birthday card \
           due:2016-11-08 \
           scheduled:due-4d \
           wait:due-7d \
           until:due+2d

task add compile Nim 1.0.4 due:3m scheduled:due-5d \
           wait:due-10d until:due+2d

在 Alice 生日(due:2016-11-08)前7天(wait:due-7d)任务进入任务列表中, 但还没到开始执行的时间,生日前4天(scheduled:due-4d)进入 ready 状态, 应该开始执行任务了。超过最后期限两天后(until:due+2d), 这个任务没必要再执行了,被自动删除。

Ref: Using Dates Effectively

Add user-defined commands

Terminology 中的 entension 说明扩展 taskwarrior 功能的3种方式,其中最简单的一种通过命令别名实现。 下面以自定义 git push remote repo 命令为例说明实现方法。

目标是执行 task bak 后,自动将 ~/.task 目录下的 pending.data 和 completed.data 的更新 push 到远端 repo 中。

实现方法:

$ cat << EOF > ~/.task/scripts/backup.sh
#!/bin/sh
cd ~/.task
echo "Backup task definitions to git repository ..."
git add pending.data completed.data
git commit -m'update task definitions'
git push
EOF

$ chmod 755 ~/.task/scripts/backup.sh
$ task config alias.bak execute ~/.task/backup.sh

然后手工在 ~/.task 下初始化 git repo,设置好 remote repo, 就可以实现 task bak 自动 push 了。

Add detailed explanations for a task

Add explanations of a task with annotate command. For example:

task 3 annotate this is some explanations

You can annotate a task more than one time.

If the annotations are very long, you can edit it in vim with task 3 edit.

Task sync

You can build your own task server (instal with apt install taskd) and create certificates by yourself. Here I use the public service inthe.am as the sync server. Login to the inthe.am with Google account. Download certificate files into folder ~/.task/certificates and add configurations into ~/.taskrc according to the instructions in Configuration > Synchronization Settings:

data.location=~/.task
taskd.certificate=~/.task/certificates/private.certificate.pem
taskd.key=~/.task/certificates/private.key.pem
taskd.ca=~/.task/certificates/ca.cert.pem
taskd.server=taskwarrior.inthe.am:53589
taskd.credentials=inthe_am/leetschau/2ec9db72-fa7f-49c5-b09c-ef01a699f255
taskd.trust=ignore hostname

Then run task sync init and that's all.

Problems

安卓版本在 Google Play 上有两个,用户评价不高,评价数量比较少(100+), 且其中一个有两年没更新了。

More notes about synchronizing, read diary at 2020.2.12 in joplin.

Timewarrior

Install and hook to taskwarrior:

sudo apt install timewarrior
cp /usr/share/doc/timewarrior/ext/on-modify.timewarrior ~/.task/hooks
chmod +x ~/.task/hooks/on-modify.timewarrior
task diagnostics  # verify: timewarrior is "active" in the "Hooks" section

Usage

task 3 start    # start time tracking
timew    # Show current task time statistics
task 3 stop     # stop time tracking
timew summary   # print time tracking report
timew summary :month
timew summary :day

Problem: can the time consumption can be summaried by project or tag?

Ref: Tracking time on the command line with Taskwarrior and Timewarrior

Todo.txt

todo.txt 使用纯文本作为数据存储, 包含一个命令行工具 todo.txt-cli 和几个安卓客户端,其中 Simpletask 可以在 设置 中与 Dropbox 绑定实现同步,可以打开桌面提醒功能。

安卓版本设置好 Dropbox 同步后,在自动 Dropbox 的 Apps 目录下创建 Simpletask 文件夹;

PC上的命令行版本安装过程:

  1. 从 Github release 上下载 最新稳定版本的 tar.gz 文件,解压到 ~/apps 文件夹下;

  2. 修改 ~/apps/todo.txt_cli-2.11.0/todo.cfg 中的数据目录: export SYNC_BASE="$HOME/Documents/Dropbox/Apps/Simpletask" export TODO_FILE="$SYNC_BASE/todo.txt" export DONE_FILE="$SYNC_BASE/done.txt" export REPORT_FILE="$SYNC_BASE/report.txt" 这里 $HOME/Documents/Dropbox 是 Dropbox 在服务器上的同步文件夹, 可以在配置菜单中修改;

  3. 设置命令简写(to):在 ~/.bash_aliases 中添加 alias to="$HOME/apps/todo.txt_cli-2.11.0/todo.sh"

  4. 实现命令补全:在 ~/.zshrc 中添加 source $HOME/apps/todo.txt_cli-2.11.0/todo_completion 实现Tab自动补全和可选命令列表;

现在可以用 to ls 列出所有任务了。

常用操作

README of todo.txt 对 todo.txt 的3个核心概念:Project, Context 和 Priority 做了细致的介绍,例如:

学习 Haskell 是一个大目标,所以是一个 project, 阅读和练习 GPH (Get Programming Haskell) 是具体步骤,所以 to a GPH +haskell(这里 a 是 add 的简写)。

这 3 个概念在 taskwarrior 里对应 project, tag, priority.

设置截止日期和优先级

下面定义一个数值分析任务,然后设置优先级为B:

$ to add "max-cur matrix-median 数值不一致问题 @office" due:2018-11-26
$ to ls
1 2018-11-25 研究Python测试工具  due:2018-12-5 t:2018-11-25
2 max-cur matrix-median 数值不一致问题 @office due:2018-11-26
--
TODO: 2 of 2 tasks shown

$ to p 2 B

这里 p 是 priority 的简写,2是任务编号。

推迟任务

给 due 设置一个很远的日期,实现推迟的效果: to a "Get Programming Haskell +haskell" due:2019-03-01

任务管理工具特征

  1. 数据保存为纯文本文件,方便实现数据保存和版本控制;

  2. 包含命令行版本和移动设备版本,能方便地在不同设备间同步;

  3. 具备PC和移动设备上的提醒功能;



Published

Nov 23, 2018

Last Updated

Sep 1, 2020

Category

Tech

Tags

  • taskwarrior 1

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor