Skip to main content
Marcel Krčah

Tracking hours with Clockify, fzf, jq and awk

Published on , in ,

For the current project, I need to track hours in Clockify. But as I was opening the webpage and filling in the hours, I felt dispassionate. So I decided to turn this activity into a joyful one.

It turns out that Clockify has an easy to use API. So I decided to build a script that 1) gets a list of all projects via an API call, 2) lets me interactively select a project, 3) lets me select duration I'd spent on the project that day, and 4) adds hours to the projects via an API call. To do the job, I summoned my favorite command-line tools:

For example, to interactively select a project id I piped the tools together:


Using the script almost every day, I'm now playfully enjoying the tracking routine.

Here's the full script:

#!/usr/bin/env bash

# fail on error, unused var and pipe failure
set -euo pipefail

# clockify api config

# let me select a project
  'X-Api-Key':"$CLOCKIFY_API_KEY" | \
  jq -r ".[] | .id, .name" | \
  awk 'NR%2{printf "(%s) ", $0;next}1' | \
  fzf --nth=2.. | \
  cut -f1 -d' ' | \
  tr -d '()'

# let me pick how many hours I worked today
HOURS=$(seq 1 12 | awk '{print $0 " hours"}' | fzf | awk '{print $1}')

# start the day at 9:00am

# and stop after $HOURS have passed

http -q $CLOCKIFY_BASE_URL/workspaces/"$CLOCKIFY_WORKSPACE_ID"/time-entries \
  'X-Api-Key':"$CLOCKIFY_API_KEY" \
  start="${TASK_STARTED_AT}Z" \
  end="${TASK_STOPPED_AT}Z" \
  projectId="$PROJECT_ID" \

echo "Done 🚀"

This blog is written by Marcel Krcah, an independent consultant for product-oriented software engineering. If you like what you read, sign up for my newsletter