yarstu, another rich terminal screenshot utility
Go to file
Daylin Morgan b53abd9cad
ci: use correct URI
2023-12-05 16:36:54 -06:00
.github/workflows ci: use correct URI 2023-12-05 16:36:54 -06:00
assets chore: add minimal logo 2023-05-15 13:07:32 -05:00
docs docs: add logo/favicon 2023-05-15 13:18:28 -05:00
scripts fix(ci): keep docs directory around 2023-05-14 20:25:33 -05:00
src/yartsu fix: don't source _run_cmd on windows 2023-12-05 16:35:33 -06:00
.flake8 feat: patch console to improve drop-shadow 2022-06-18 16:52:48 -05:00
.gitignore fix(ci): keep docs directory around 2023-05-14 20:25:33 -05:00
.pre-commit-config.yaml fix(ci): keep docs directory around 2023-05-14 20:25:33 -05:00
.task.cfg.mk chore: switch to .task.cfg.mk 2023-04-26 17:26:31 -05:00
LICENSE chore: drop .txt 2023-05-11 11:56:38 -05:00
Makefile chore: add minimal logo 2023-05-15 13:07:32 -05:00
README.md docs: generate better documentation 2023-05-14 14:19:25 -05:00
mkdocs.yml docs: add logo/favicon 2023-05-15 13:18:28 -05:00
pdm.lock docs: generate better documentation 2023-05-14 14:19:25 -05:00
pyoxidizer.bzl build: switch build framework to pyoxidizer 2022-06-16 01:19:48 -05:00
pyproject.toml docs: generate better documentation 2023-05-14 14:19:25 -05:00
todo.md todo: 2 tasks completed 2023-05-14 20:38:26 -05:00

README.md

Yartsu

Logo

yartsu, another rich terminal screenshot utility

Documentation


Stargazers Issues MIT License

NOTE: this is a currently in a beta release and the API is subject to change (feedback welcome)

Inspired by recent commits in the wonderful library rich I decided to write yartsu.

I needed to programmatically generate screenshots for documentation purposes. The new export_svg methods in rich were a godsend. So I wanted to try to make this feature a little more generalizable to program output outside of rich/python. Hopefully, you find it useful.

If you come across anything unexpected please submit an issue.

Install

pipx install yartsu
# OR
pip install yartsu

Releases

There is a standalone binary available for linux in the releases (Support for additional platforms is planned).

Optionally install with eget:

eget daylinmorgan/yartsu

Otherwise you can download an extract manually to somewhere on your path.

Usage

Logo

Getting a properly formatted output from a terminal screenshot is challenging.

There are three options for generating a screenshot.

If one of the below option causes you any headaches consider first trying a different option.

Option 1: Pipes

Many tools that color output (i.e. grep or ls) additionally allow you to force ANSI color codes to be included even when piping output.

In these cases you can simply pipe the output directly into yartsu

ls --color=always | yartsu -w 50 -o assets/ls_color.svg

Option 2: Subprocess/Pty

With this option yartsu will deploy a subprocess and pty to run your command for you in an attempt to preserve ANSI.

Note with this option you need to separate the command you want to run with yartsu args using --.

yartsu -w 50 -o assets/ls_color.svg -- ls --color /

Option 3: Text File

Finally, if you neither of the above options work and you can manage to preserve the codes in a plain text file you can pass this as input to yartsu.

ls --color > ls.txt
yartsu -w 50 -i ls.txt -o assets/ls_color.svg

By default svgs will be saved at ./capture.svg.

Additionally, for options 1 and 3 you may want to define your own title with -t/--title. For option 2 the title will by default be the cmd ran by yartsu.

Themes

There are a number of themes you can use to style output. Use yartsu --list-themes to see the available options. Then you can specify the theme you want with --theme, i.e. yartsu --theme rich_default. You may also use the environment variable YARTSU_THEME.

See here a preview of the available themes

Differences from Rich

For both practical and stylistic reasons the underlying code used to generate the SVG is slightly different than rich's default save_svg method. See here for the current deviation between the latest releases of each respective release.