Home Productivity Tools How To Track Your Time In Linux With Bartib

How To Track Your Time In Linux With Bartib

Boost Productivity: Time Tracking with Bartib in Linux

By sk

As IT professionals, we often need to track the time we spend on our assignments - whether it is for internal reporting in our company or for billing our clients. While many tools exist to fulfill different needs, many of them cater to bigger teams or special needs but lack the simplicity we enjoy when using command line tools. One simple tool, which allows us to track time directly on the command line is Bartib.

What is Bartib?

Bartib provides several commands to track when we start and stop activities or to create reports on how much time we spent on certain tasks and projects. It saves a log of all tracked activities as a plain text file in a simple, human readable format.

Bartib is free and opensource application written in Rust.

Install Bartib in Linux

Bartib can be installed via Homebrew, the Cargo package manager, or by downloading precompiled binaries from the release page.

Method 1: Installation via Homebrew

Install Homebrew

If you have not yet installed Homebrew on your computer, please do so before proceeding:

Install Bartib

Once Homebrew is installed, Bartib can be installed using the following command:

$ brew install bartib

Method 2: Installation via Cargo

Install Rust

If Rust is not installed on your Linux machine, it needs to be installed before proceeding:

Update Rust (if already installed):

Make sure you have the latest version of Rust by executing the following command:

$ rustup update

Install Bartib

Once Rust has been updated, you can proceed to install Bartib using the Cargo package manager. Execute the following command:

$ cargo install --locked bartib

Method 3: Installation via Precompiled Binaries

You can obtain a precompiled binary from the project's release page at the Bartib's Release Page. Download the tar file that corresponds with your architecture, extract it, and relocate the executable to a directory in your $PATH.

If you plan to use Bartib with your individual user account only, the directory might be ~/bin. However, if you intend to make Bartib available for all users on your device, the directory would be /usr/local/bin.

After installing Bartib, ensure that it's executable by setting the correct file permissions with the following command:

$ chmod 755 bartib

Alternatively, you have the option to install the pre-built binaries utilizing a shell script that you find on Bartib's release page. Just execute the following command, and the shell script will install Bartib straight to your system:

$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/nikolassv/bartib/releases/download/v1.1.0/bartib-installer.sh | sh

Install Bartib from AUR

If you're on Arch Linux and its variants like EndeavourOS and Manjaro Linux, you can install Bartib from Arch User Repository (AUR) using Paru:

$ paru -S bartib

Or Yay AUR helper:

$ yay -S bartib

Install Bartib in Alpine Linux

Bartib is available in the default repositories of Alpine Linux. You can install it using apk command like below:

$ sudo apk add bartib

Test if Bartib has Been Installed Successfully

After you have installed Bartib, you want to confirm that the installation was successful. Simply enter this command in your terminal, and it should present the installed version of Bartib:

$ bartib --version

How to Track your Time in Linux using Bartib

Tell Bartib where to Save the Log of Your Activities

As already mentioned above, Bartib records a log of all your activities in a plain text file. To be able to log any activity, Bartib must know where to locate this file. You designate the file explicitly in every command using the -f or --file flag, as follows:

$ bartib -f ~/activities.bartib report

Alternatively, Bartib permits to specify the file via the BARTIB_FILE environment variable. You should ideally define this variable in a file like .bashrc, which is executed in any shell you open, as such:

export BARTIB_FILE=activities.bartib

When the BARTIB_FILE environment variable is present, there's no need to employ the -f flag. As this method is the preferred way of specifying the file, the -f flag is disregarded in all of the subsequent examples.

Simple Time Tracking: Starting and Stopping Activities

You use Bartib by issuing the bartib command with a subcommand and optional parameters. In this regard it works much the same as other command line tools like git.

The subcommands you may need the most in your daily work are the start and stop command. As each activity in Bartib consist of a description and project, you have to define these as parameters with the start subcommand:

$ bartib start -d 'Fix javascript bug #345' -p 'Application Front End'

The -d or --description parameter sets the description, the -p or --project parameter sets the project.

After you have completed your task, you can stop tracking the time with:

$ bartib stop

You may also just start the next activity. Bartib will stop all running activities automatically when a new activity commences.

If you have been working for a while and are unsure if you have successfully started tracking your time, use the bartib current command to verify if bartib is tracking any activity and if so which. If you forgot to start the activity you can still start it later and set its start time using the -t parameter in 24 hour format:

$ bartib start -d 'Improve Database Performance' -p 'Housekeeping' -t 15:30

Two other command for starting activities come in handy, if you frequently switch between tasks. The first one is bartib last which displays a list of recently used combinations of descriptions and projects. The second one is bartib continue which allows you to continue any of these recent activities.

The output of bartib last shows an index for each activity in its first column:

bartib last Command Output
bartib last Command Output

You use this index with bartib continue to specify which activity to continue:

$ bartib continue 5
Started activity: "Team meeting" (Internal project) at 2024-05-17 18:03

You may also overwrite the description or the project by re-defining it by the respective parameter as well as set the start time with the -t parameter:

$ bartib continue 5 -d 'Fix Bug #56' -t 10:45

Listing Activities and Creating Reports

To list which activities you have tracked so far, use the list subcommand:

$ bartib list
The bartib list Command Output
The bartib list Command Output

It is often desirable to only list tasks in a certain period. You may define such a period with the --from and --to parameters:

$ bartib list --from 2024-05-13 --to 2024-05-17

If both dates are the same, you set them with a single --date argument:

$ bartib list --date 2024-05-15

Bartib provides several parameters to define often used time periods:

$ 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

It is often desirable to list all the activities you have tracked for a specific project. In this case, you can use the --project filter with bartib list:

$ bartib list --project 'Development of the Application Backend'

While it is helpful to be able to list all tracked activities, what makes Bartib truly useful is its ability to create meaningful reports.

Use the subcommand bartib report to create a report comprising all the activities you have ever tracked:

$ bartib report
The bartib report Command Output
The bartib report Command Output

As you see in the output above, Bartib lists all projects and under each project it provides a list of all activities belonging to this project. It displays the time that you have spent on each tasks and the total time that you have spent on each project. It also calculates the sum of all activities that you have ever tracked.

The bartib report command accepts the same parameters as bartib list to filter the tasks that it includes. Just as with bartib list, you use the --from and --to parameters to set a period for which you want to report, or you can use one of the predefined periods: --today, --yesterday, --current_week and --last_week.

Changing Time Tracking Entries

Sometimes, you might need to modify the activities that you have tracked. To alter the currently running activity, Bartib offers the bartib change command. Simply use it with the -p, -d or -t parameter to change its project, its description or its start time.

For example, the following command changes the start time of the currently running activity to 10:15:

$ bartib change -t 10:15

If you have already started tracking any activity but have changed your mind and do not wish to track anything at all, you can use the bartib cancel subcommand. It removes any currently tracked activity for good, while it won't touch any other activity in your log.

If you need to modify any activities that have already stopped, you can still alter its record in the activities log. Simply open the file in you favorite editor or use the bartib edit command to start the editor defined in your $EDITOR environment variable.

The format of a record is self-explanatory:

2024-05-13 10:15 - 2024-05-13 14:00 | Development of the Application Back end | Fixing the Logging endpoint

Each record consists of parts delimited by the pipe sign "|". The first part contains the start and end times, the second part the project and the third part the task description.

After you have manually altered the activities, you might want to use the bartib check and the bartib sanity command.

The former verifies whether the log contains any invalid lines that bartib won't be able to parse, while the latter checks whether the log contains any activities with logical errors, like an activity with a negative duration.

For detailed usage, check the Bartib GitHub repository:


As simple as Bartib is to use, it is a remarkably versatile tool for tracking activities on the command line. While it does not offer all the feature other tools provide, it is truly useful for anyone who wants to track times as a single user in a hassle-free way.

Related: Moro – A Command Line Productivity Tool For Tracking Work Hours

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More