Skip to main content

OSC 7501

Python Version License Tests PyPI PyPI Downloads

Report terminal program status with OSC 7501.

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 supports OSC 7501
  • 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")

working() writes working when you call it, before the with block. Enter writes nothing more. 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

Which terminals show a report is tracked in the awesome-osc7501 matrix. This library does not wrap reports for tmux.

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

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

Built distribution (wheel)

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

Total release size: 27.7 kB

Release files / osc7501-1.0.2.tar.gz

Download URL osc7501-1.0.2.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bf19096dee09e74a4e7c6e7682e296e303b6c45f96965ef60ab45795a797cb53
BLAKE2b-256 checksum
How to use checksums
3e69dce84a7a5314a4b8ad3219d3699255c5f9d217fb432a605e76585c74573d
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.2-py3-none-any.whl

Download URL osc7501-1.0.2-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fca9f180016c418f22da2273e8aa1e423d5602a021f26695586553c52146a33
BLAKE2b-256 checksum
How to use checksums
22b287f359f65223d9f5f07f7ab1bff32751e98c9dc2b3945baf31e65257093e
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

This release

1.0.2 This release

2 release files

1.0.1

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