Skip to main content

Format xonsh history to post it to Github or another page.

The mission of xontrib-hist-format is to make commands repeatable, copy-pastable and save time to preparing.

If you like the idea click ⭐ on the repo and stay tuned.

Installation

xpip install xontrib-hist-format
# or: xpip install -U git+https://github.com/anki-code/xontrib-hist-format

Usage

Starting from xonsh 0.10.0 (4283) it's needed to set $XONSH_CAPTURE_ALWAYS before using xontrib-hist-format. Be careful by using this setting and read the env variable description.

$XONSH_CAPTURE_ALWAYS = True
xontrib load hist_format
hist-format --help         # Basic command
hist-md                    # Markdown format shortcut
hist-txt                   # Text format shortcut

Arguments:

usage: hist-format [-h] [-f FORMAT] [-c COMMANDS_COUNT] [-l]
                   [-H [OUTPUT_HEAD_COUNT]] [-T [OUTPUT_TAIL_COUNT]]
                   [-m] [--lines]

Format xonsh history to post it to Github or another page.

optional arguments:
  -h, --help            show this help message and exit
  -f FORMAT, --format FORMAT
                        Format: md, txt.
  -c COMMANDS_COUNT, --commands-count COMMANDS_COUNT
                        Count of commands
  -l, --commands-list   Show commands in distinct section.
  -H [OUTPUT_HEAD_COUNT], --output-head-count [OUTPUT_HEAD_COUNT]
                        Count of lines from output head to show.
  -T [OUTPUT_TAIL_COUNT], --output-tail-count [OUTPUT_TAIL_COUNT]
                        Count of lines from output tail to show.
  -m, --min             Make block minimized i.e. by adding <details> tag in Markdown.
  --lines               Add additional lines before and after.

Note! The clear command is used as marker of the beginning of commands list. If you run commands 1, 2, 3 then run clear, and run 4, 5, 6 and finally run hist-md it will show 4, 5, 6 commands. Feel free to open an issue with feedback on this approach.

Example

Run commands:

echo 123
ls / | head -n 3

Run hist-format:

hist-md -c 2 -l --lines    # latest 2 commands + commands list + header and footer as line

As result you will get the output that you can copy and paste to the Github comment or md-file:


Output:

echo 123
#123

ls / | head -n 3
#boot
#cdrom
#dev

# Prepared by xontrib-hist-format

Commands:

echo 123
ls / | head -n 3

# Prepared by xontrib-hist-format

You can disable the "Prepared by" message by setting XONTRIB_HIST_FORMAT_FOOTER = '' in your environment. If you like this xontrib, tell your friends!


Clipboard

You can redirect the output to clipboard. Example for xclip:

hist-md | xclip

Known issues

Not every command has output in the __xonsh__.history.

Workaround in some cases is to use pipe into head i.e. cat file | head.

Credits

Metadata

Release files for xontrib-hist-format 0.0.14

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

Source distribution (sdist)

Source distribution for xontrib-hist-format 0.0.14
File Size Uploaded Provenance Actions
xontrib_hist_format-0.0.14.tar.gz 4.8 kB Without provenance Details for xontrib_hist_format-0.0.14.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-hist-format 0.0.14
File Interpreter ABI Platform Actions
xontrib_hist_format-0.0.14-py3-none-any.whl Python 3 none any Details for xontrib_hist_format-0.0.14-py3-none-any.whl

Total release size: 9.9 kB

Release files / xontrib_hist_format-0.0.14.tar.gz

Download URL xontrib_hist_format-0.0.14.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b6a0dd2602396704d36307c9d44b97d72fad4bc7261db724ef2a50a239ac41b7
BLAKE2b-256 checksum
How to use checksums
4ac09168615818583da46fa818f3d376744e3cf384060a6cb1db515bf1587bf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / xontrib_hist_format-0.0.14-py3-none-any.whl

Download URL xontrib_hist_format-0.0.14-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9e718280f1b0bd0d8554d71fb2d08a1f58e8d503c44b51745fb292ab312ce33
BLAKE2b-256 checksum
How to use checksums
eb6466204c5b7a856e26741b9aa8bd52b893b4643ae6e3c9853eb578a32775c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for xontrib-hist-format 0.0.14

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

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