sphinx-terminal
sphinx-terminal allows you to display terminal input and output in your Sphinx documentation.
Basic usage
To display terminal input and output in your Sphinx document, use the terminal
directive, providing input and output as follows:
.. terminal::
input
output
Input can span multiple lines, as long as the lines are in the same paragraph. Everything after the first blank line in the directive's body is rendered as output.
The prompt defaults to user@host:~$. To customize this, use the :user:, :host:,
and :dir: options.
.. terminal::
:user: author
:host: canonical
:dir: ~/path
echo 'hello'
hello
Or, declare the entire prompt with the prompt option. This is useful if you're
documenting shells other than Bash, such as PowerShell:
.. terminal::
:prompt: PS C:\Users\Author>
Write-Output 'hello'
hello
To render only the output of a command, include the :output-only: flag in the
directive's options.
.. terminal::
:output-only:
This is rendered as output.
To enable a copy button for users, include the :copy: flag as a directive option.
Only the input can be copied.
.. terminal::
:copy:
echo 'hello'
hello
Similarly, to make the output scrollable, include the :scroll: flag as a directive
option.
.. terminal::
:scroll:
echo 'hello'
hello
Project setup
sphinx-terminal is published on PyPI and can be installed with:
pip install sphinx-terminal
After adding sphinx-terminal to your Python project, update Sphinx's conf.py file to include sphinx-terminal as one of its extensions:
extensions = [
"sphinx_terminal"
]
The copy button functionality depends on sphinx-copybutton. sphinx-terminal automatically adds this extension to your Sphinx project and configures it to copy terminal input and ignore the multiline prompt.
copybutton_selector = "span.copybutton, div:not(.terminal-code) > div.highlight > pre"
copybutton_prompt_text = "> |"
copybutton_prompt_is_regexp = True
Customizing these values in your conf.py file overrides the defaults assigned by sphinx-terminal and may compromise the copy button.
Community and support
You can report any issues or bugs on the project's GitHub repository.
If you're interested in contributing, start with the contribution guide.
sphinx-terminal is covered by the Ubuntu Code of Conduct.
License and copyright
sphinx-terminal is released under the GPL-3.0 license.
© 2025 Canonical Ltd.
Metadata
Release files for sphinx-terminal 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx_terminal-1.1.0.tar.gz | 106.1 kB | With provenance | Details for sphinx_terminal-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_terminal-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for sphinx_terminal-1.1.0-py3-none-any.whl |
Total release size: 127.4 kB
Release files / sphinx_terminal-1.1.0.tar.gz
| Download URL | sphinx_terminal-1.1.0.tar.gz |
|---|---|
| Size | 106.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
447d883c33a6d790b66bc23cce90ef5ce87d19af63ff4bbb8d44eb441152333a
|
|
BLAKE2b-256 checksum How to use checksums |
f96a8a40612509f222dc966d80f9438f6780c3a0b7ed6e849420e9d277e0e15f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 16, 2026.
Transparency logRelease files / sphinx_terminal-1.1.0-py3-none-any.whl
| Download URL | sphinx_terminal-1.1.0-py3-none-any.whl |
|---|---|
| Size | 21.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a2985d7982b68cd2271473148c65ccef62259ef644b5b76053cd709a5e15175d
|
|
BLAKE2b-256 checksum How to use checksums |
6ce209e3f6530238d3a654a74ca36af4187be72938f8adfcf9b0fd24bf92fe06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jul 16, 2026.
Transparency logSecurity for sphinx-terminal 1.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sphinx_terminal-1.1.0.tar.gz
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 Jul 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.