tasks 查询语法能干什么?
简单来说,就是根据已经输入的任务信息。对任务进行查询,按照我们设定好的条件,展示不同的效果。灵活定制,想你所想。
[!success] 提示 tasks 能够实现市面上的各类TODO软件的收费功能。当然这需要你熟悉他的一些配置。
tasks演示效果:
用tasks实现的查询效果,都是自动刷新,自动查询的。
tasks演示1:obsidian四象限
tasks演示2:obsidian回顾面板
实现按照天、周、月份、年度的展示回顾任务。方便自己对整体任务的掌握。
添加任务了解参数
[!success] 提示 在我们开始使用tasks前,需要检查基础配置,回顾上一章节的知识。[[Tasks进阶用法(一)]]
系统默认任务,或者tasks插件,都需要了解任务在markdown语法中的几种状态和相关参数。
设置全局过滤标签
[!warnning] 注意 强烈推荐:安装 tasks 插件后,开启 Global task filter 全局标签过滤。
- 打开插件 → 设置 找到tasks ,找到 Global task filter 全局标签过滤
- 在这里填写
#task
。意思是过滤包含#task
标签的任务。
添加任务的方法
详见 [[Tasks进阶用法(一)#使用]] 按Ctrl+鼠标点击新窗口打开
- 命令面板,输入 task,选择Tasks: Create or edit task。
-
但是更推荐自定义快捷键快速插入任务,我的自定义是
Ctrl + T
[!danger] danger 自定义快捷键 推荐自定义快捷键快速插入任务,我的自定义是
Ctrl + T
。下面不再解释 在obsidian 设置 → 快捷键 → 搜索:tasks
找到 edit。给他添加快捷键
任务状态待办和完成
示例:
– [ ] 这个是待办事项
– [x] 这个是待办事项完成
– [x] #task 这个是tasks插件添加的任务
实战1.添加任务
任务的参数
- Description:任务描述,就是正文
-
Priority:重要程度,依次是 Low 低、Normal一般、Medium中等、High高
-
Recurs:循环任务,按周期
-
Due:到期时间
-
Scheduled:计划任务
-
Start:开始时间
-
Status 状态
- todo,计划
-
Done
-
In Progress
-
Cancelled
查询任务完成日期
[!success] 设计原则 在这里,我将tasks插件的用法进行了拆解,没有按照官方来讲解。官方的过于复杂,然后逻辑有点混乱,不太适合新手使用。我们先易后难,先用起来再说。
[!danger] 掌握任务和日期就够了 使用最多的就是任务完成状态,还有日期。掌握这个就足够使用tasks了
日期 Date
首先,日期 date 可以用自然语言或者具体的日期。如果是在tasks插件输入时间可以输入范围。由tasks插件计算时间。比如 3 day
,会自动计算3天之后的具体时间。
[!success] 提示 这是 tasks 插件中使用最多的参数,设定日期。包括开始时间、到期时间、重复时间等等。只要涉及到日期就是在这里使用。
- due <到期时间>
- start <开始时间>
- Scheduled <计划时间>
准确的查询语法类似due 日期
,日期可以是以下形式:
具体日期
2023-02-14
相对日期
yesterday
today
tomorrow
this week/month
next week/month
weekend
in three weeks
last Monday
next Friday
14 days ago
in two weeks
重复日期⏰
every 3 days (每3天)
every 10 days when done
every weekday (meaning every Mon – Fri)
every weekday (表示每周一至周五)
every week on Sunday (每周日)
every 2 weeks(每两周一次)
every 3 weeks on Friday (每3周的周五
every 2 months (每两月一次)
every month on the 1st (每月1号)
every month on the last
every month on the last Friday
every month on the 2nd last Friday
every 6 months on the 2nd Wednesday 每过6个月的第2个星期三1次
every January on the 15th
every February on the last
every April and December on the 1st and 24th (meaning every April 1st and December 24th)
every April and December on the 1st and 24th (指每年4月1日和12月24日)
every year (每年)
[!success] 日期的优先顺序
- Due date 到期日
- Scheduled date 预订日期
- Start date 开始日期
任务完成 Done
任务完成状态:
- 完成的任务,使用
done
-
未完成的任务,使用
not done
任务和日期 Done & Date
任务完成时间:
done (before, after, on) <date>
,-
完成在(之前,之后,在某天) 日期
-
done before 1 week,在之前一周完成的
任务是否有日期:
has done date
有完成日期-
no done date
没有完成日期 -
done date is invalid
完成日期无效(比如2.30日)
[!success] 释义 before=之前,after=之后,on=在
实战2:使用时间和完成状态查询任务
所有未完成任务
not done
所有完成任务
done
今天到期的所有未完成任务
not done
due today
限定范围的所有未完成任务
not done
due after yesterday
due before in two weeks
组合查询条件
多个条件使用布尔运算符连接:
当单一的查询,无法准确的确定范围时。我们可以将几个查询条件组合使用
[!success] 注意大写 查询条件用
(查询条件)
圆括号包裹,查询条件之间使用布尔运算符连接,运算符如下,注意使用大写:
- AND,同时满足⭐️常用
-
OR,或者,任选其一⭐️常用
-
NOT,否,不是⭐️常用
-
AND NOT,要求第一个过滤器匹配,第二个过滤器不匹配
-
OR NOT,要求第一个筛选器匹配,或第二个筛选器不匹配
-
XOR,只需要两个筛选器中的一个进行匹配,不要将两个以上的XOR筛选器组合在一起
[!danger] 注意
- 查询条件用
(查询条件)
圆括号包裹,查询条件之间使用布尔运算符连接。- 运算符注意使用大写
- 圆括号不能省略,否则报错。
- 组合条件可超过2个,但XOR不能同时两个以上(不含两个)
举例:
AND 同时
(due after yesterday) AND (due before in two weeks)
OR 任选其一
(tags include #inbox) OR (path includes Inbox) OR (heading includes Inbox)
(tag includes #XX) OR (tag includes #YY) AND (tag includes #ZZ)
( (tag includes #XX) AND (tag includes #YY) ) OR (tag includes #ZZ)
NOT 否,不是❓
NOT (path includes inbox)
AND NOT
注释:要求第一个过滤器匹配,第二个过滤器不匹配
(has start date) AND NOT (description includes some)
OR NOT
注释:要求第一个筛选器匹配,或第二个筛选器不匹配
(has start date) OR NOT (description includes special)
XOR
只需要两个筛选器中的一个进行匹配,不要将两个以上的XOR筛选器与组合在一起
[!success] 布尔运算适可而止 不需要使用过于复杂的 布尔运算 进行筛选,常用的就是前面三个。太复杂的查询反而是个负担
查询条件组合不要过多:
- 查询条件不要嵌套太多,2~3个就可以了。
-
查询布尔运算尽量使用前面三个,后面过于复杂建议不使用,避免绕脑!
布尔运算执行优先级
运算符按以下顺序计算:
NOT
-
XOR
-
AND
-
OR
实战3:使用组合查询
AND 同时
not done
(due after yesterday) AND (due before in two weeks)
- 没有完成
-
昨天到期的 同时 2周后到期的 (也就是从昨天~到两周后区间范围的)
OR 任选其一
(tags include #inbox) OR (path includes Inbox) OR (heading includes Inbox)
(tags include #DailyNote) OR ((path includes daily/Notes/Folder/) AND (path does not include 2022-07-11))
标签 包括 `#inbox`) 或者 (路径 包括 Inbox) 或者 (标题 包括 Inbox) 以上条件任选其一,满足其中任意一个即可
(tags include `#DailyNote`) OR ((path includes daily/Notes/Folder/) AND (path does not include 2022-07-11)) 我希望查看保管库中任何位置带有标记的任务或每日便笺文件夹中的任务,但不希望查看今天的每日便笺中的任务。 `#DailyNote`
**NOT 否,不是❓**
NOT (path includes inbox)
- NOT (path includes inbox)
- 路径里不包含“inbox”
AND NOT
(has start date) AND NOT (description includes some)
- 要求第一个过滤器匹配,第二个过滤器不匹配
-
(has start date) AND NOT (description includes some) =>
- AND (All of):
- has start date
-
NOT:
- description includes some
- AND (All of):
OR NOT
(has start date) OR NOT (description includes special)
- 要求第一个筛选器匹配,或第二个筛选器不匹配
-
(has start date) OR NOT (description includes special) =>
- OR (At least one of):
-
has start date
-
NOT:
- description includes special
[!danger] 尽量使用前面三个 查询布尔运算尽量使用前面三个,后面过于复杂建议不使用,避免绕脑!
控制结果的显示样式
显示样式布局有以下选项:可以设置为 show
和 hide
edit button
编辑按钮-
backlink
反向链接 -
urgency
紧迫性 -
priority
重要等级 -
start date
开始日期 -
scheduled date
计划日期 -
due date
到期日期 -
done date
完成日期 -
recurrence rule
-
task count
任务数量统计
隐藏样式
hide due date // 隐藏 到期日期
hide backlink // 隐藏 baklink
hide start date // 隐藏 开始日期
hide done date // 隐藏 完成日期
hide edit button // 隐藏 编辑按钮
显示样式
show due date // 隐藏 到期日期
show backlink // 隐藏 baklink
show start date // 隐藏 开始日期
show done date // 隐藏 完成日期
show edit button // 隐藏 编辑按钮
综合查询项
是否完成
done # 任务完成, done/not done
not done # 没有完成
date时间
due # 到期时间
start # 开始时间
Scheduled # 计划时间
Recurring
周期性任务 every week/every month/every month on the last
显示样式 show/hide 显示隐藏
show due date # 展示 到期日期
hide backlink # 隐藏 baklink
hide start date # 隐藏 开始日期
hide done date # 隐藏 完成日期
hide edit button # 隐藏 编辑按钮
short mode # 短模式,按照一定的规则
重要程度
priority is high
priority is low
priority is medium
low,medium,high 分别是低/中/高
是否重复
is recurring
includes 包含
第一位 description 是可以查询的位置,
可用的有description 任务描述、path文件路径、filename、heading、tag、tags
description includes obsidian # 【任务描述】中包含了“关键字”
path includes obsidian # 【路径】中包含了“关键字”
filename includes obsidian # 【文件名】中包含了“文件名”
heading includes obsidian # 【标题】中包含了“关键字”
tag includes obsidian # 【标签】中包含了“关键字”
tags includes obsidian # 【标签】复数中包含了“关键字”
组合查询
not done
未完成的任务
due after yesterday
due before in 2 month
到期时间(昨天~2月之后)
✅无误,日期核对是准确的,从今天开始两个月时间
show due date
显示到期时间
hide backlink
hide start date
hide done date
sort by due
排序
sort by d
task语法查速查表
过滤器 | 排序 | 分组 | 显示 |
---|---|---|---|
done not done |
sort by status |
group by status |
|
done (before, after, on) <date> has done date no done date done date is invalid |
sort by done |
group by done |
hide done date |
status.name (includes, does not include) <string> status.name (regex matches, regex does not match) /regex/i |
sort by status.name |
group by status.name |
|
status.type (is, is not) (TODO, DONE, IN_PROGRESS, CANCELLED, NON_TASK) |
sort by status.type |
group by status.type |
|
starts (before, after, on) <date> has start date no start date start date is invalid |
sort by start |
group by start |
hide start date |
scheduled (before, after, on) <date> has scheduled date no scheduled date scheduled date is invalid |
sort by scheduled |
group by scheduled |
hide scheduled date |
due (before, after, on) <date> has due date no due date due date is invalid |
sort by due |
group by due |
hide due date |
happens (before, after, on) <date> has happens date no happens date |
sort by happens |
group by happens |
|
is recurring is not recurring |
group by recurring |
||
recurrence (includes, does not include) <string> recurrence (regex matches, regex does not match) /regex/i |
group by recurrence |
hide recurrence rule |
|
priority is (above, below, not)? (low, none, medium, high) |
sort by priority |
group by priority |
hide priority |
sort by urgency |
show urgency |
||
path (includes, does not include) <path> path (regex matches, regex does not match) /regex/i |
sort by path |
group by path |
|
group by root |
|||
group by folder |
|||
filename (includes, does not include) <filename> filename (regex matches, regex does not match) /regex/i |
sort by filename |
group by filename |
|
heading (includes, does not include) <string> heading (regex matches, regex does not match) /regex/i |
sort by heading |
group by heading |
|
group by backlink |
hide backlink |
||
description (includes, does not include) <string> description (regex matches, regex does not match) /regex/i |
sort by description |
||
tag (includes, does not include) <tag> tags (include, do not include) <tag> tag (regex matches, regex does not match) /regex tags (regex matches, regex does not match) /regex/i |
sort by tag sort by tag <tag_number> |
group by tags |
|
组合过滤器 | |||
(filter 1) AND (filter 2) |
|||
(filter 1) OR (filter 2) |
|||
NOT (filter 1) |
|||
(filter 1) XOR (filter 2) |
|||
(filter 1) AND NOT (filter 2) |
|||
(filter 1) OR NOT (filter 2) |
|||
(filter 1) AND ((filter 2) OR (filter 3)) |
|||
exclude sub-items |
|||
limit to <number> tasks limit <number> |
|||
其他布局选项 | |||
hide edit button |
隐藏编辑按钮 | ||
hide task count |
隐藏任务统计 | ||
short mode |
短模式(简洁显示任务信息) |
必须 注册 为本站用户, 登录 后才可以发表评论!