A zsh hook for command status in the sidebar (not just agents) #223
Replies: 2 comments
-
|
A few changes since the first post:
Also fixed a restart bug: every session came back with a running badge that never cleared. Two causes. words=(${(z)1}); w=${${(Q)words[1]}:t} # 'claude' -> claude ; /path/to/claude -> claudeThe quoting only bites after a restart, since typing Same link: https://github.com/rashpile/agterm-experimental/tree/main/shell/zsh |
Beta Was this translation helpful? Give feedback.
-
|
this is really a cool idea! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
agterm's shipped shell integration lights the sidebar glyph while a coding agent runs. I wanted the same
signal for ordinary commands, so I wired up a small zsh hook that drives
agtermctl session statusfromany command's lifecycle:
--auto-reset, so you only see it on a tab you're not looking at — switch tothat tab and it clears
The case it's for is walking away: start a build or a test run, move to another tab, and the first one
goes green or amber when it's done.
How it works:
preexecsetsactive;precmdreads$?and the command's duration and setscompleted/blocked, or clears back toidlefor anything under ~10s (and for agent and interactivecommands, so it stays out of the shipped integration's way). Both status writes are synchronous — two
async writes from back-to-back commands can arrive out of order and leave a stuck glyph.
I also give the command badges slightly lighter tints than the default
active/completedcolours, so arunning command reads differently from a running agent in the sidebar.
Script and a longer writeup: https://github.com/rashpile/agterm-experimental/tree/main/shell/zsh
Beta Was this translation helpful? Give feedback.
All reactions