Skip to main content

OSC 7501

Python Version License Tests PyPI PyPI Downloads

Report terminal program status with OSC 7501. Inspired by the osc-status npm package.

Features

  • States: idle, working, done, blocked, error, and clear
  • One job: a context manager that repeats app, id, and title and closes the job for you
  • Safe text: control characters become spaces before base64, so one newline cannot drop the report
  • Optional probe: ask the terminal whether it implements revision 0.4
  • Zero dependencies: the library only uses the Python standard library
  • TTY gate: reports are skipped when stderr is a pipe, unless you pass enabled=True

Why OSC 7501?

OSC 9;4 progress can say that a program is busy, at a percentage, or failed. It has no message and no way to say the program is waiting on the user. A window title is one free-form string.

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, so sending a report is safe.

Spec: Program Status Protocol, revision 0.4 (2026-10-10).

Installation

pip install osc7501

Usage Examples

Helpers

from osc7501 import blocked, done, working

working(progress=40, msg="Building docs")
blocked(kind="permission", msg="Approve deploy?")
done(msg="Docs built")

Each report replaces the terminal's record. Repeat every field you still want. clear() with no id removes every record in the terminal.

Reports go to stderr, and only when it is a terminal.

One job

from osc7501 import working

with working(app="make", msg="Building docs") as job:
    job.blocked(kind="question", msg="Overwrite config.toml?")
    job.done(msg="Docs built")

Enter writes working. A clean exit writes done with no message. An exception writes error. KeyboardInterrupt writes idle. If you already called job.done() or job.error(), the exit writes nothing.

msg for kind="auth" is the prompt, never the secret.

Detection

from osc7501 import detect

print(detect().result)

Call detect() before reading input. It can consume keystrokes typed during the wait. On Windows, or when /dev/tty cannot be opened, the result is Detection.UNKNOWN. Helpers never probe on their own.

Where reports show up

This list is from the awesome-osc7501 matrix dated 2026-10-11. It was not re-checked for this release.

Shows reports: Rex, TUIOS, termio, SwiftTerm, Termy, con-terminal, phux, thurm, wietty, Prowl.

Ignores reports: the Ghostty app (libghostty parses them; the app does not opt in), tmux (drops them unless DCS passthrough and allow-passthrough are on; this release does not wrap them), Kitty, WezTerm, Alacritty, iTerm2, Windows Terminal, VS Code, Zed, Warp, zellij.

API Reference

Name Description
encode(state, *, msg, title, app, id, kind, progress) -> str Build one sequence. Does not write.
working(*, msg, title, app, id, progress, stream, enabled) -> Job Write working and return a Job.
Job.update(*, progress, msg) -> bool Write another working report. Skips a byte-identical repeat.
Job.blocked(*, kind, msg, progress) -> bool Write blocked, repeating app, id, and title.
Job.done(*, msg) -> bool / Job.error / Job.idle Write that state.
idle, done, error, blocked, clear Write one report. Return True only when bytes were written.
query() -> str The OSC 7501 ; ? ST query.
parse_reply(sequence) -> Support | None Parse one reply. Missing lists mean the five states and three kinds.
detect(*, timeout=0.2) -> Support Probe /dev/tty. Support.supported is true only for Detection.SUPPORTED.
State, Kind StrEnum values. Plain strings are accepted too.

Learn More

Acknowledgments

Built and maintained by

osc7501 is built and maintained by:

Name GitHub Role
Y. Siva Sai Krishna Y. Siva Sai Krishna @ysskrishna Creator

Changelog

See CHANGELOG.md for a detailed list of changes and version history.

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

If you find this library helpful:

  • ⭐ Star the repository
  • 🐛 Report issues
  • 🔀 Submit pull requests
  • 💝 Sponsor on GitHub

License

MIT © Y. Siva Sai Krishna - see LICENSE file for details.


Author's GitHub • Author's LinkedIn • Report Issues • Package on PyPI

Metadata

Release files for osc7501 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for osc7501 1.0.0
File Size Uploaded
osc7501-1.0.0.tar.gz 16.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for osc7501 1.0.0
File Interpreter ABI Platform
osc7501-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.0 kB

Release files / osc7501-1.0.0.tar.gz

Download URL osc7501-1.0.0.tar.gz
Size 16.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cdc441383d379cbce0ab91bb44fd1d998bd72f15256cbaf06e4cd304b216bc68
BLAKE2b-256 checksum
How to use checksums
08b44169c43719df8755d92316bfa639c42b876ff03000b362a99653eb1f3d03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / osc7501-1.0.0-py3-none-any.whl

Download URL osc7501-1.0.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68d7e79d310f256b34e3ab1749c8e54323f250fe0c50fe480ca63d3cefb2bb20
BLAKE2b-256 checksum
How to use checksums
e60f0fb964a5b6a5ebf91a70cb58fe40882bbdd312fac40f63c3fe86d449dd4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

1.0.2

2 release files

1.0.1

2 release files

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page