nikolassv / bartib

A simple timetracker for the command line. It saves a log of all tracked activities as a plaintext file and allows you to create flexible reports.
GNU General Public License v3.0
670 stars 35 forks source link

My starship config for bartib. #30

Open berkes opened 11 months ago

berkes commented 11 months ago

Hi,

Thanks for the great software! Very much appreciated that you put it out there!

I'm not sure where I can put this, so I'll leave it in a ticket for now. Let me know if you want it in a special place and I'll whip up a PR.

I'm using starship to fancyfy my console. I've added bartib to that, and thought maybe others can benefit too.

image

I thought I'd share my setup. It's simple but wiring up required some trial-and-error, grep/pipe stuff.

The idea is simple, just add a custom command to starship.toml config.

[custom.bartib]
style = "bg:#06969A"
format = "[$symbol ($output) ]($style)"
command = "bartib current | head -n 3 | tail -n 1 | tr -d '\n'"
when = "bartib current | grep -q -v 'No Activity is currently running'"
symbol = "⏲️ "

Then use it in the prompt somewhere. E.g.:

format = """
.... your other format strings.... |${custom.bartib} >
"""

What it does is ugly. And I'll clean it up once I can propose some features to bartib ;).

Hope it helps someone. Feel free to close if this is not needed or wanted.

dj8yfo commented 11 months ago

this is pretty awesome, just the thing i was looking for, should definetely be added to documentation as a standard recipe

lutzzdias commented 7 months ago

After messing around with chatGPT, having @berkes command as the starting point, I was able to get the following command: command = "bartib current | head -n 3 | tail -n 1 | sed 's/[[:space:]]\\{2,\\}/ /g' | awk '{print $4, \"-\", $5}'"

head and tail serve the same purpose, sed removes the whitespace between items, keeping only 1 space and awk is used to get only specific values.

Where:

My command will result in: `{project} - {time}'

But you could edit the awk part in order to customize it e.g awk '{print $4 \",\", $3, \"-\", $5}' = {project}, {description} - {time}

In the end, my starship config was the following:

[custom.bartib]
format = '[󰥔  $output]($style) '
style = "bold #a9b1d6"
command = "bartib current | head -n 3 | tail -n 1 | sed 's/[[:space:]]\\{2,\\}/ /g' | awk '{print $4, \"-\", $5}'"
when = "bartib current | grep -q -v 'No Activity is currently running'"

which resulted in:

image