Skip to content

tnwei/nbread

Repository files navigation

nbread

Snappy previews of Jupyter notebooks from the command line

Use case

  • Read notebooks using just the terminal, don't need to spin up a Jupyter Notebook / Lab instance
  • Read superlarge notebooks without chugging Jupyter Notebook / Lab

Usage

Run nbread notebook.ipynb for notebook preview in terminal.

$ nbread --help
usage: nbread [-h] [--no-pager] [--experimental-images] filename

positional arguments:
  filename

optional arguments:
  -h, --help              show this help message and exit
  --no-pager              Disable pager and print directly to stdout
  --experimental-images   Enable experimental Sixel image rendering (disables pager,
                          requires compatible terminal and chafa)

Paging: Defaults to 'less' with auto-exit. Override with $PAGER env var or
disable with --no-pager. Set PAGER='' to disable paging via environment.

Try it out with the notebooks bundled in tests/!

Experimental: Image Support

nbread supports rendering images in notebooks using Sixel graphics. This feature is experimental and requires:

  • A Sixel-compatible terminal (e.g., xterm, mlterm, foot, wezterm, konsole, contour). Check Are We Sixel Yet for a latest up-to-date list
  • chafa installed (install via your package manager: sudo apt install chafa, brew install chafa, sudo dnf install chafa etc.)

To enable image rendering:

nbread --experimental-images notebook.ipynb

Note: The --experimental-images flag automatically disables the pager since Sixel graphics don't work correctly in pagers. For notebooks with images, you'll see the full output printed directly to your terminal.

Setup

One of the following:

pip install git+https://github.com/tnwei/nbread

pipx install git+https://github/com/tnwei/nbread

uv tool install git+https://github/com/tnwei/nbread

Integrations

Appreciation

Code heavily based on Textualize/rich-cli's notebook pretty printing.

About

Snappy previews of Jupyter notebooks from the command line

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published