Live Hackfetch
New milestone today: hackfetch can now stay open and update itself while you code.
The goal was simple: run hackfetch once, leave it in the corner of your terminal, and watch the numbers move in real time as you work.
hackfetch -watch
Your today-hours tick up. Your top project changes when you switch repos. Your streak rolls over at midnight. All without running the command a second time.
The static render was already in place from the regular one-shot fetch. The new part was redrawing without scrolling.
That sounds simple. It is not.
In a terminal, every time you print something, it appends to the bottom of the screen. By default, refreshing the fetch would just print a second copy of itself underneath the first, then a third, then a fourth. Within a minute you’d have a wall of identical fetches scrolling away into the past.
The trick is ANSI escape codes. There’s a sequence that means “move the cursor up N lines” and one that means “clear the rest of the screen from here down.” Together they let you erase the previous fetch and redraw a new one in the same spot. Same screen, fresh data, no scroll.
Why every 30 seconds? Two reasons:
Hackatime aggregates heartbeats in 1-minute buckets internally, so polling faster than that doesn’t tell you anything new 30 seconds is fast enough to feel “live” without hammering the API for no reason
Ctrl+C to quit. Resizing the terminal doesn’t break it. Pair it with a gradient color scheme and the whole thing turns into a tiny dashboard for your coding session:
hackfetch -watch sunset
Comments 1
this looks super cool!
Sign in to join the conversation.