Skip to content

The day in your prompt

How long have I worked today? Is kasl still recording? Did something new land in the inbox? kasl status answers all three in one line, made for a prompt:

6h 40m | paused 12m | inbox 9 (3 new)

watch off takes the place of the pause when no watcher is running - the segment that matters most, because then nothing is being recorded. The whole format is on the status page.

The command reads the local database and the watcher’s PID file only - never the network, never an update check - and prints nothing at all when there is nothing to say, so the segment simply disappears.

In ~/.config/starship.toml:

[custom.kasl]
command = "kasl status"
when = true
format = "([$output]($style) )"
style = "bold green"

The parentheses make the group conditional: with nothing printed, not even the space after it is left. On Windows add shell = ["cmd", "/C"], so starship does not start a PowerShell for every prompt just to run one command.

In ~/.tmux.conf:

Terminal window
set -g status-right '#(kasl status) '
set -g status-interval 30

In your profile ($PROFILE), around your existing prompt:

Terminal window
$KaslPrompt = $function:prompt
function prompt {
$line = kasl status
if ($line) { Write-Host "[$line] " -NoNewline -ForegroundColor DarkGreen }
& $KaslPrompt
}

The line is plain ASCII, so it reads the same whatever code page the console is in.

~/.bashrc
PS1='$(s=$(kasl status); [ -n "$s" ] && printf "[%s] " "$s")'"$PS1"
~/.zshrc
setopt PROMPT_SUBST
PROMPT='$(s=$(kasl status); [[ -n $s ]] && print -n "[$s] ")'"$PROMPT"

A bar that draws its own pieces - waybar, polybar, a Rainmeter skin - reads kasl status --json instead and picks the fields it needs: work_seconds, watcher, state, paused_since, inbox.fresh. A bar that only shows text can take line from the same document. See JSON output.

Terminal window
# waybar: a custom module's exec
kasl status --json | jq -c '{text: .line, class: (.state // "off")}'