Report terminal program status with OSC 7501
When it's useful
A long-running program can be working, finished, failed, or waiting on the user. OSC 9;4 can say busy, a percentage, or failed, and it has no message. OSC 7501 adds a state, a reason (permission, question, or auth), and a stable app name. The terminal decides how to show that. A terminal that does not know the sequence ignores it.
What you can do
- Send
idle,working,done,blocked,error, orclear. - Track one job with
working()as a context manager. It repeatsapp,id, andtitle, and writes the closing state for you. - Optionally probe the terminal with
detect()before you read input.
Limits and fit
Python 3.11+. The library has no runtime dependencies. Reports go to stderr, and only when stderr is a terminal, unless you pass enabled=True. This release follows Program Status Protocol revision 0.4. Examples are in the GitHub repository.






