Toggl Time Tracking
Use the toggl CLI (@beauraines/toggl-cli) for Toggl Track integration.
Prerequisites
Install the CLI:
CODEBLOCK0
Configure authentication (create ~/.toggl-cli.json):
CODEBLOCK1
Get your API token from: https://track.toggl.com/profile
Get your workspace ID from your Toggl URL: INLINECODE2
Set permissions: INLINECODE3
Commands
Status
CODEBLOCK2
Start/Stop
CODEBLOCK3
Continue Previous
CODEBLOCK4
Reports
CODEBLOCK5
List Entries
CODEBLOCK6
Add Completed Entry
CODEBLOCK7
Edit Current
CODEBLOCK8
Delete
CODEBLOCK9
Projects
CODEBLOCK10
Other
CODEBLOCK11
Notes
- - Times must be parsable by dayjs (e.g.,
4:50PM, 12:00 AM, 9:00) - Config file: INLINECODE7
- Environment variables override config:
TOGGL_API_TOKEN, TOGGL_DEFAULT_WORKSPACE_ID, INLINECODE10
Toggl 时间追踪
使用 toggl 命令行工具(@beauraines/toggl-cli)进行 Toggl Track 集成。
前提条件
安装命令行工具:
bash
npm install -g @beauraines/toggl-cli
配置身份验证(创建 ~/.toggl-cli.json):
json
{
apitoken: 你的TOGGLAPI_TOKEN,
defaultworkspaceid: 你的工作区ID,
timezone: 你的/时区
}
从以下地址获取 API 令牌:https://track.toggl.com/profile
从你的 Toggl URL 获取工作区 ID:https://track.toggl.com/{工作区ID}/...
设置权限:chmod 600 ~/.toggl-cli.json
命令
状态
bash
toggl now # 显示正在运行的计时器
toggl me # 显示用户信息
开始/停止
bash
toggl start # 开始计时(交互式)
toggl start -d 任务名称 # 带描述开始
toggl start -d 任务 -p 项目 # 带项目开始
toggl stop # 停止当前计时器
继续上一个
bash
toggl continue # 重新开始最近的条目
toggl continue 关键词 # 重新开始匹配关键词的条目
报告
bash
toggl today # 今日按项目统计的时间
toggl week # 按天统计的周摘要
列出条目
bash
toggl ls # 最近14天
toggl ls -d 7 # 最近7天
toggl ls --today # 仅今日
toggl ls 搜索词 # 搜索条目
添加已完成条目
bash
toggl add 9:00AM 10:30AM 会议记录
编辑当前条目
bash
toggl edit -s 10:00AM # 更改开始时间
toggl edit -d 新描述 # 更改描述
toggl edit -p 项目 # 更改项目
删除
bash
toggl rm
# 按ID删除条目
项目
bash
toggl project ls # 列出项目
其他
bash
toggl web # 在浏览器中打开Toggl
toggl create-config # 生成配置模板
注意事项
- - 时间必须能被 dayjs 解析(例如:4:50PM、12:00 AM、9:00)
- 配置文件:~/.toggl-cli.json
- 环境变量可覆盖配置:TOGGLAPITOKEN、TOGGLDEFAULTWORKSPACEID、TOGGLTIMEZONE