taskwarrior ,一款提升效率的命令行 TODO list 工具
taskwarrior 是一款 Free and Open Source 的 TODO list 管理工具。他的特点是灵活以及快速,不仅仅支持本地保存 task 的信息,还可以通过连接到 taskserver,同步任务列表到云端。 对我这种平时工作在 Linux 下的命令行用户来说,效率特别高。
1. taskwarrior 安装
软件的安装在 taskwarrior 的 github 主页有很清晰的描述。目前最新的开发版本是 2.6.0。
2. task 的使用
创建 task: task add "任务名称"
▸ task add "write an article of InfoQ"
Created task 1.
▸ task add "write code with timer"
Created task 2.
复制代码
查看 task ,以 task 的紧急情况排序: task list 或者直接 task
▸ task list
ID Age Description Urg
1 2min write an article of InfoQ 0
2 1min write code with timer 0
2 tasks
复制代码
特别地,针对上述打印,做下参数介绍,这些参数可以说就是每一个 task 的 metadata(备注:后续随着介绍的深入,还会不断出现新的 metadata):
标记 task 状态,这个章节开始之前,需要介绍下命令 task info
,这个命令是查看 task 的信息的.
▸ task info
Name Value
------------- ------------------------------------
ID 1
Description write an article of InfoQ
Status Pending
Entered 2021-04-11 09:01:55 (16min)
Start 2021-04-11 09:10:53
Last modified 2021-04-11 09:10:53 (7min)
Virtual tags ACTIVE PENDING READY UNBLOCKED
UUID 06a55fe1-de2f-4b0b-801e-0c3c1232241b
Urgency 4
---------- ------ - ---- - ------
active 1 * 4 = 4
------
4
Date Modification
------------------- -----------------------------------
2021-04-11 09:10:53 Start set to '2021-04-11 09:10:53'.
Name Value
------------- ------------------------------------
ID 2
Description write code with timer
Status Pending
Entered 2021-04-11 09:02:45 (15min)
Last modified 2021-04-11 09:02:45 (15min)
Virtual tags LATEST PENDING READY UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
Urgency 0
复制代码
▸ task info 2
Name Value
------------- ------------------------------------
ID 2
Description write code with timer
Status Pending
Entered 2021-04-11 09:02:45 (26min)
Last modified 2021-04-11 09:02:45 (26min)
Virtual tags LATEST PENDING READY UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
Urgency 0
复制代码
标记 task 开始: task [ID] start
▸ task 2 start
Starting task 2 'write code with timer'.
Started 1 task.
复制代码
task 2 start
前后对 task 2 的 info 对比:
--- /tmp/info.2 2021-04-11 09:29:09.812011298 +0800
+++ /tmp/info_20 2021-04-11 09:36:52.817549855 +0800
@@ -1,12 +1,22 @@
Name Value
-------------- ------------------------------------
+------------- --------------------------------------
ID 2
Description write code with timer
Status Pending
-Entered 2021-04-11 09:02:45 (26min)
-Last modified 2021-04-11 09:02:45 (26min)
-Virtual tags LATEST PENDING READY UNBLOCKED
+Entered 2021-04-11 09:02:45 (34min)
+Start 2021-04-11 09:35:38
+Last modified 2021-04-11 09:35:38 (1min)
+Virtual tags ACTIVE LATEST PENDING READY UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
-Urgency 0
+Urgency 4
+
+---------- ------ - ---- - ------
+ active 1 * 4 = 4
+ ------
+ 4
+
+Date Modification
+------------------- -----------------------------------
+2021-04-11 09:35:38 Start set to '2021-04-11 09:35:38'.
复制代码
可以看出,关键的地方有三处:
标记 task 暂停: task [ID] stop
▸ task 2 stop
Stopping task 2 'write code with timer'.
Stopped 1 task.
复制代码
接着刚才,再次对比 task stop 前后 task info 的差异:
--- /tmp/info_20 2021-04-11 09:36:52.817549855 +0800
+++ /tmp/info_21 2021-04-11 09:43:28.628006126 +0800
@@ -1,22 +1,17 @@
Name Value
-------------- --------------------------------------
+------------- ------------------------------------
ID 2
Description write code with timer
Status Pending
-Entered 2021-04-11 09:02:45 (34min)
-Start 2021-04-11 09:35:38
-Last modified 2021-04-11 09:35:38 (1min)
-Virtual tags ACTIVE LATEST PENDING READY UNBLOCKED
+Entered 2021-04-11 09:02:45 (40min)
+Last modified 2021-04-11 09:41:08 (2min)
+Virtual tags LATEST PENDING READY UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
-Urgency 4
-
----------- ------ - ---- - ------
- active 1 * 4 = 4
- ------
- 4
+Urgency 0
Date Modification
------------------- -----------------------------------
2021-04-11 09:35:38 Start set to '2021-04-11 09:35:38'.
+2021-04-11 09:41:08 Start deleted (duration: 0:05:30).
复制代码
差异主要也有三点,其中两点又回到了 task start 之前的状态,包括删除了 ACTIVE 标签,没有了 Status 条目中没有了 Start 的时间,但是 stop 的命令也在 task 的动态更新条目中添加了一条状态. 可以相信后续围绕 task 的每一次操作都会被记录在这里.
3. 标记 task 完成: task [ID] done
▸ task 2 done
Completed task 2 'write code with timer'.
Completed 1 task.
You have more urgent tasks.
复制代码
再次对比 task done 前后 task info 的信息,让我们看看 task done 有没有特别的变化.
--- info_21 2021-04-11 09:43:28.628006126 +0800
+++ info_22 2021-04-11 09:50:41.917600209 +0800
@@ -3,15 +3,18 @@
------------- ------------------------------------
ID 2
Description write code with timer
-Status Pending
-Entered 2021-04-11 09:02:45 (40min)
-Last modified 2021-04-11 09:41:08 (2min)
-Virtual tags LATEST PENDING READY UNBLOCKED
+Status Completed
+Entered 2021-04-11 09:02:45 (47min)
+End 2021-04-11 09:49:56
+Last modified 2021-04-11 09:49:56 (45s)
+Virtual tags COMPLETED LATEST UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
Urgency 0
Date Modification
-------------------- -----------------------------------
+------------------- ---------------------------------------------
2021-04-11 09:35:38 Start set to '2021-04-11 09:35:38'.
2021-04-11 09:41:08 Start deleted (duration: 0:05:30).
+2021-04-11 09:49:56 End set to '2021-04-11 09:49:56'.
+ Status changed from 'pending' to 'completed'.
复制代码
可以看出,差异点主要也有三个:
* 添加 End 一条的时间
* 删除了 PENDING 和 READY 的虚拟标签,添加了 END 的虚拟标签
* 除了在 task 的状态修改列表中添加了一栏之外,还增加一句 Status changed from 'pending' to 'completed'
到这个地方表示这个 task 已经完成,我们再看看我们的 task list:
▸ task
[task next]
ID Active Age Description Urg
1 50min 59min write an article of InfoQ 4
1 task
复制代码
可以看出此时已经被 task done
的 task 2 已经在 task list 上看不到了.如果这时候尝试根据之前的 ID == 2 去查看呢,会出现什么呢?
▸ task info 2
No matches.
复制代码
很不幸查不到了.这时候如果想查看已完成的需要使用命令还是 task info [ID]
,不过这时候 ID 就不能是 2 了,以为 task list 中没有 2 这个 task,此时就要使用之前的 UUID 这个 metadata . 再回到之前 task 还在 list 列表的时候, task 2 的 info 中有一段 UUID baff9051-1647-4e99-acae-7e8ff410d7a3
,这个 UUID 可以认为就是这个 task 的身份信息,这个是唯一的.所以这时候虽然我们可以通过 task info baff9051-1647-4e99-acae-7e8ff410d7a3
查看 write code timer 的 task 的信息了. 这个 UUID 类似 git 的 commit id,可以选取前面的几位保证唯一行就可以,这里也可以使用 baff9051
这段 ID 就可以.
▸ task info baff9051-1647-4e99-acae-7e8ff410d7a3
Name Value
ID -
Description write code with timer
Status Completed
Entered 2021-04-11 09:02:45 (1h)
End 2021-04-11 09:49:56
Last modified 2021-04-11 09:49:56 (24min)
Virtual tags COMPLETED LATEST UNBLOCKED
UUID baff9051-1647-4e99-acae-7e8ff410d7a3
Urgency 0
Date Modification
2021-04-11 09:35:38 Start set to '2021-04-11 09:35:38'.
2021-04-11 09:41:08 Start deleted (duration: 0:05:30).
2021-04-11 09:49:56 End set to '2021-04-11 09:49:56'.
Status changed from 'pending' to 'completed'.
复制代码
如果直接 task done
会出现什么呢?让我们拭目以待:
▸ task done
This command has no filter, and will modify all (including completed and deleted) tasks. Are you sure? (yes/no) yes(首次使用会提示你没有设置过滤,这样的会现实所有已完成和删除的 task,选择 yes 就可以)
Completed task 1 'write an article of InfoQ'.
Task baff9051 'write code with timer' is neither pending nor waiting.
Completed 1 task.
复制代码
实现的效果就是标记所有当前所有的状态的 task 为 done 状态,所以 task done 的时候记得添加参数啊.
4. 删除 task, task [ID] delete
.到目前位置我们已经将所有的 task 都标记为 done 了,这时候,让我们删除一个 task 试下,因为这时候已经 没有 task 在 task list 了,因为 task list 列出的都是 pending 状态的 task(不包括 done 和 delete 的).参考之前的 ID 就需要用到 UUID 了.这次我们就删除 UUID 是 06a55fe1
的 task 了.
▸ task 06a55fe1 delete
Delete task 06a55fe1 'write an article of InfoQ'? (yes/no) yes(会提示你是否确认删除这个 task,输入 yes 确认)
Deleting task 06a55fe1 'write an article of InfoQ'.
Deleted 1 task.
Note: Modified task 06a55fe1 is completed. You may wish to make this task pending with: task 06a55fe1 modify status:pending
复制代码
这时候需要再介绍一个命令 task stats
统计当前所有的 tasks 的信息.
▸ task stats
Category Data
------------------------- -------------
Pending 0
Waiting 0
Recurring 0
Completed 1
Deleted 1
Total 2
Annotations 0
Unique tags 0
Projects 0
Blocked tasks 0
Blocking tasks 0
Data size 5.2 KiB
Undo transactions 10
Sync backlog transactions 10
Tasks tagged 0%
Oldest task 2021-04-11
Newest task 2021-04-11
Task used for 50s
Task added every 25s
Task completed every 50s
Task deleted every 50s
Average time pending 1h
Average desc length 23 characters
复制代码
可以看出当前一共有 2 和 task,其中一个是 Completed 状态另一个是 Deleted 状态.其他的一些 metadata 后续遇到会展开描述.
如果想恢复已经删除的 task 怎么办呢?刚才的打印已经提示了,需要标记 task 的 status 状态为 pending.
▸ task 06a55fe1 modify status:pending
Modifying task 06a55fe1 'write an article of InfoQ'.
Modified 1 task.
▸ task list
ID Age Description Urg
- 1h write an article of InfoQ 0
1 task
复制代码
可以看出来,"write an artivle of InfoQ" 的 task 又恢复了.
同样的对已完成的 task 也可以通过 UUID 匹配到指定的 task,然后恢复 task.考虑到后续高阶部分演示需要,这里我将另一个 completed 的 task 也置未 pending 状态:
▸ task baff9051 modify status:pending
Modifying task baff9051 'write code with timer'.
Modified 1 task.
复制代码
修改 task 的 metadata 信息
▸ task
[task next]
ID Age Description Urg
1 1h write an article of InfoQ 0
2 1h write code with timer 0
▸ task 1 modify priority:H
Modifying task 1 'write an article of InfoQ'.
Modified 1 task.
▸ task
[task next]
ID Age P Description Urg
1 1h H write an article of InfoQ 6
2 1h write code with timer 0
2 tasks
▸ task
[task next]
ID Age P Description Urg
1 1h H write an article of InfoQ 6
2 1h L write code with timer 1.8
2 tasks
▸ task 2 modify priority:M
Modifying task 2 'write code with timer'.
Modified 1 task.
▸ task
[task next]
ID Age P Description Urg
1 2h H write an article of InfoQ 6
2 1h M write code with timer 3.9
2 tasks
复制代码
可以看出 H 的优先级为 6, M 为 3.9, L 为 1.8 (urg 的数值会随着任务数量等因素动态发生变化,但是 H > M > L 是肯定的).
▸ task
[task next]
ID Age P Description Urg
1 2h H write an article of InfoQ 6
2 1h M write code with timer 3.9
2 tasks
▸ task 2 modify due:2011-04-11
Modifying task 2 'write code with timer'.
Modified 1 task.
复制代码
重点来了, 我们再看下 task list
:
▸ task
[task next]
ID Age P Due Description Urg
2 2h M -10.0y write code with timer 15.9
1 2h H write an article of InfoQ 6
2 tasks
复制代码
可以看到因为截止时间快要到了,这个 task 的 urg 值已经从之前的 1.8 提高到了 15.9 表示已经特别急迫了.除此之外,还可以通过修改添加 tag 的方法修改 urg.
▸ task 1 modify +next
The 'next' special tag will boost the urgency of this task so it appears on the 'next' report.
Modifying task 1 'write an article of InfoQ'.
Modified 1 task.
▸ task
[task next]
ID Age P Tag Due Description Urg
1 2h H next write an article of InfoQ 21.8
2 2h M -10.0y write code with timer 15.9
2 tasks
复制代码
可以看到 task 2 的 urg 又被反超了. next
的 tag 表示这个 task 是下一个就要急迫做的 task.
创建 task 之间的依赖,这里修改 task1 是 task2 的依赖,比如只有完成了 task1 才可以执行 task2,需要修改 depends 这个 metdata:
▸ task 2 modify depends:1
Modifying task 2 'write code with timer'.
Modified 1 task.
▸ task
[task next]
ID Age Deps P Tag Due Description Urg
1 2h H next write an article of InfoQ 29.8
2 2h 1 M -10.0y write code with timer 10.9
2 tasks
复制代码
可以看出来通过不同的颜色标识这两个 task 之间存在依赖关系.
创建 project 组下的 tasks
▸ task add project:reading read book 0
Created task 3.
The project 'reading' has changed. Project 'reading' is 0% complete (1 task remaining).
▸ task add project:reading read book 1
Created task 4.
The project 'reading' has changed. Project 'reading' is 0% complete (2 of 2 tasks remaining).
▸ task add read book 2
Created task 5.
▸ task add read book 4
Created task 6
▸ task
[task next]
ID Age Deps P Project Tag Due Description Urg
1 2h H next write an article of InfoQ 29.8
2 2h 1 M -10.0y write code with timer 10.9
3 15s reading read book 0 1
4 8s reading read book 1 1
5 3s read book 2 0
6 2s read book 4 0
6 tasks
复制代码
可以看出,新创建了 4 个 task:read book 0,1,2,3, 其中 read book 0,1 直接在创建的时候就关联到了 project: reading.这时候如果想将 read book 2,3 关联到 project 还是直接修改 metadata:
▸ task 5 modify project:reading
Modifying task 5 'read book 2'.
Modified 1 task.
The project 'reading' has changed. Project 'reading' is 0% complete (3 of 3 tasks remaining).
▸ task 6 modify project:reading
Modifying task 6 'read book 4'.
Modified 1 task.
The project 'reading' has changed. Project 'reading' is 0% complete (4 of 4 tasks remaining).
▸ task
[task next]
ID Age Deps P Project Tag Due Description Urg
1 2h H next write an article of InfoQ 29.8
2 2h 1 M -10.0y write code with timer 10.9
3 4min reading read book 0 1
4 4min reading read book 1 1
5 4min reading read book 2 1
6 4min reading read book 4 1
6 tasks
复制代码
可以看到已经关联到了 project: reading. 如果只想看 reading 这个 project 包含的 tasks,可以直接使用过滤器:
▸ task project:reading
[task next ( project:reading )]
ID Age Project Description Urg
3 4min reading read book 0 1
4 4min reading read book 1 1
5 4min reading read book 2 1
6 4min reading read book 4 1
4 tasks
复制代码
评论