3个稳定版本
1.1.0 | 2024年2月29日 |
---|---|
1.0.1 | 2021年11月25日 |
1.0.0 | 2021年11月16日 |
#300 in 命令行工具
115KB
2.5K SLoC
Bartib
Bartib 是一款易于使用的命令行时间追踪工具。它将所有追踪的活动记录保存为纯文本文件,并允许您创建灵活的报告。
内容
教程
爱丽丝不再追逐白兔了。现在她有了真正的工作,有真正的客户和项目经理。因此,她必须记录她如何使用工作日的小时。看看爱丽丝如何使用 Bartib 来做这件事,并了解您也可以如何使用它。
早上8点,爱丽丝来到办公室。她的项目经理给她发了一封电子邮件,要求她立即开始从《重要项目A》的《紧急任务X》工作。所以爱丽丝在命令行输入
alice@work: ~ $ bartib start -d "Urgent Task X" -p "Important Project"
Bartib 确认了
Started activity: "Urgent Task X" (Important Project) at 2021-10-29 08:00
8点43分,她的一个同事过来,他们决定喝杯咖啡。由于她不能将这段时间计入客户账单,爱丽丝在 Bartib 中停止了正在运行的活动
alice@work: ~ $ bartib stop
Stopped activity: "Urgent Task X" (Important Project) started at 2021-10-29 08:00 (43m)
大约10分钟后,她回到桌边继续工作
alice@work: ~ $ bartib continue
Started activity: "Urgent Task X" (Important Project) at 2021-10-29 08:51
10点13分,另一封电子邮件到来:《紧急任务X》必须等待!现在必须立即执行《更紧急的任务Y》,来自《另一个项目B》。
爱丽丝输入
alice@work: ~ $ bartib start -d "More Urgent Task Y" -p "Just Another Project B"
Stopped activity: "Urgent Task X" (Important Project) started at 2021-10-29 09:01 (1h 12m)
Started activity: "More Urgent Task Y" (Just Another Project B) at 2021-10-29 10:13
看看 Bartib 如何在开始另一个活动时停止正在运行的活动?无需手动停止。
今天是个高效的一天。在处理了《更紧急的任务Y》之后,爱丽丝开始着手其他项目和任务,但现在到了午饭时间,爱丽丝让巴蒂列出她今天到目前为止跟踪的所有活动。
alice@work: ~ $ bartib list --today
Started Stopped Description Project Duration
08:00 08:43 Urgent Task X Important Project 43m
08:51 10:13 Urgent Task X Important Project 1h 22m
10:13 10:35 More Urgent Task Y Just Another Project B 22m
10:35 10:53 Urgent Task X Important Project 18m
10:53 11:45 Simple Task Z Less Important Project 52m
11:45 12:34 Boring Task XY Internal Project C 49m
午餐后,爱丽丝想要继续处理《更紧急的任务Y》。为了避免再次输入任务描述和项目名称,她向巴蒂要了一份她最近完成的所有任务的清单。
alice@work: ~ $ bartib last
# Description Project
[3] More Urgent Task Y Just Another Project B
[2] Urgent Task X Important Project
[1] Simple Task Z Less Important Project
[0] Boring Task XY Internal Project C
她指示巴蒂继续任务#3。
alice@work: ~ $ bartib continue 3
Started activity: "More Urgent Task Y" (Just Another Project B) at 2021-10-29 12:52
工作日继续充满活力。由于今天是星期五,爱丽丝决定在七点稍后就已经离开。她停止了最新的活动,并让巴蒂提供一份报告。
alice@work: ~ $ bartib report --today
Important Project................................. 2h 43m
Another Task xyz.............................. 15m
Important Call with the Client................ 35m
Urgent Task X................................. 1h 53m
Internal Project C................................ 4h 30m
Another Meeting............................... 45m
Boring Task XY................................ 1h 15m
Long Meeting with Everyone from the Department 2h 30m
Just Another Project B............................ 45m
More Urgent Task Y............................ 45m
Less Important Project............................ 2h 27m
Simple Task No. 5............................. 1h 35m
Simple Task Z................................. 52m
Total............................................. 10h 25m
爱丽丝很高兴。这只是在公司度过的又一个美好的一天,多亏了巴蒂跟踪时间,工作变得轻而易举。
你想要像爱丽丝一样快乐吗?试试巴蒂!
如何 ...
如何安装 Bartib
下载可执行文件
只需从https://github.com/nikolassv/bartib/releases下载一个合适的可执行文件,并将其复制到你的PATH
中列出的某个目录(例如,~/bin)。
使用 Cargo
你也可以使用cargo从crates.io安装巴蒂。
cargo install bartib
从 AUR (Arch Linux)
yay -S bartib
通过 homebrew
brew install bartib
通过 apk (Alpine Linux)
apk add bartib
(目前巴蒂只在测试仓库中可用)
通用包装状态
如何构建 Bartib
巴蒂是用rust编写的。你可以使用cargo的帮助自己构建它。只需在其主目录中执行cargo build
命令即可。
cargo build --release
如何指定保存活动日志的文件
你可以指定日志的绝对路径作为额外参数(--file
或-f
)传递给巴蒂命令。
bartib -f /home/username/activities.bartib report
或者,你可以设置环境变量BARTIB_FILE
为日志的路径。只需将此行添加到你的.profile
文件中。
export BARTIB_FILE="/home/username/activities.bartib"
如果指定的日志文件尚未存在,巴蒂会创建它。
如何编辑或删除追踪的活动
只需在你的最喜欢的文本编辑器中打开活动日志来编辑或删除以前的活动。你甚至可以手动在此文件中添加新活动。格式是自我解释的。
巴蒂甚至提供了bartib edit
命令,该命令会使用由你的EDITOR
环境变量定义的编辑器打开日志。如果你不确定你的编辑是否可由巴蒂读取,请使用bartib check
命令。它将通知你任何解析错误。
如何启用自动完成
巴蒂甚至提供了对项目名称的简单自动完成。这使你不必每次开始新任务时都输入冗长的项目名称。只需在你的.bashrc
中source脚本misc/bartibCompletion.sh即可启用它。
对于fish用户,请将misc/bartib.fish添加到~/.config/fish/completions/
或~/.local/share/fish/vendor_completions.d/
目录中。目前,你必须在你的fish shell中设置BARTIB_FILE
以启用项目和描述名称的自动完成。
命令概览
所有这些命令都需要你设置环境变量BARTIB_FILE
为活动日志的文件路径。否则,它们需要在bartib
和子命令之间添加额外的-f/--file
参数(见上文:如何定义要保存活动日志的文件)。
基本操作
bartib -h # get help
bartib start -p "name of the project" -d "description of the activity" # start a new activity
bartib stop # stop an activity
bartib list --today # list all activities of the current day
bartib report --today # create a report for today
获取帮助
bartib -h # Print a concise help
bartib start -h # Print a help for any subcommand
追踪活动
bartib start -p "The name of the associated project" -d "A description of the activity" # Start a new activity with a short description and an associated project
bartib start -p "The name of the associated project" -d "A description of the activity" -t 13:45 # Start a new activity at a given time
bartib stop # Stop the currently running activity
bartib stop -t 14:00 # Stop the currently running activity at a given time
bartib last # Print a list of the ten most recently used projects and descriptions
bartib last -n 25 # Prints a list of recently used projects and descriptions with more entries
# All numbers used with the following commands refer to the indexes in the list created with `bartib last`
bartib continue 5 # Start an activity with a recently used project and description
bartib continue # Continue the latest activity
bartib continue 3 -d "Another description" # Continue activity number 3 but overwrite the description
bartib continue 7 -t 8:15 # Continue activity number 7 but have it started at a given time
bartib cancel # Cancels a running activity by deleting its entry in the activity log
报告和列出活动
bartib report # create a report of how much time has been spent on which projects and activities
bartib report --today # create a report for today
bartib report --yesterday # create a report for yesterday
bartib report --current_week # create a report for the current week (since monday)
bartib report --last_week # create a report for the last week
bartib report --date 2021-09-03 # create a report for a given day
bartib report --from 2021-09-01 --to 2021-09-05 # create a report for a given time range
bartib report --project "The most exciting project" # create a report for a given project
bartib report --project "Maint?nance *" # use '?' and '*' as wildcards in project names
bartib report --round 15m # rounds the start and end time to the nearest duration. Durations can be in minutes or hours. E.g. 15m or 4h
bartib list # list all activities grouped by day
bartib list --no_grouping # list all activities but do not group them by day
bartib list --today # list todays' activities
bartib list --yesterday # list yesterdays' activities
bartib list --current_week # list activities of the current week (since monday)
bartib list --last_week # list activities of the last week
bartib list --date 2021-09-03 # list activities on a given day
bartib list --from 2021-09-01 --to 2021-09-05 # list activities in a given time range
bartib list --project "The most exciting project" # list activities for a given project
bartib list --round 15m # rounds the start and end time to the nearest duration. Durations can be in minutes or hours. E.g. 15m or 4h
编辑活动
bartib change -d "A new description" # change the description of the current activity
bartib change -p "Another project" # change the project for the current activity
bartib change -t 8:15 # change the start time of the current activity
bartib edit # open the activity log in the editor you have defined in your `EDITOR` environment variable
bartib edit -e vim # open the activity log in a given editor
其他功能
bartib current # show currently running activity
bartib projects # list all projects ever used
bartib projects -c # show current project only
bartib check # check your activity log for invalid lines
bartib sanity # check for activities with logical errors (e.g activities with negative duration)
依赖关系
~2.3–3.5MB
~50K SLoC