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.1

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.1
File Size Uploaded
osc7501-1.0.1.tar.gz 17.4 kB Details

Built distribution (wheel)

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

Total release size: 27.8 kB

Release files / osc7501-1.0.1.tar.gz

Download URL osc7501-1.0.1.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0dc028732fbe9cb09ce4196b9e12d71e807e00cac633f80e8426ee83a856774a
BLAKE2b-256 checksum
How to use checksums
572fe4ed2aeb37d44f70de2cb4c3a85567791211bb3461a6569fd1c9dc09661c
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.1-py3-none-any.whl

Download URL osc7501-1.0.1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8726497920f2c55d047cea19fbe25638888eae1423ad5258f778d4c17bc30b43
BLAKE2b-256 checksum
How to use checksums
7918cd0678c8cdf74b2f7d7a52fb6d1b5b25c9151970f2c4250d522371f5969e
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

This release

1.0.1 This release

2 release files

1.0.0

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