Command Line Slideshows in Bash

At PyConf Hyderabad, I spoke about uv. It’s a package manager for Python.

I usually mix live demos into my narrative. So, rather than present with something static like PowerPoint (or Google Slides), I usually use:

For this talk, I needed to run commands on the shell. I evaluated:

  • VS Code + Terminal. Split screen is good. But slides in VS code were not obvious.
  • Web App. Write a web shell with xterm.js and node-pty and embed it in RevealJS. But it’s too much work.
  • Web terminals: WeTTY, ttyd, GoTTY, etc. But they struggle on Windows. I’d need WSL or Docker.
  • Asciinema. But it’s not interactive.

So I got ChatGPT to write me an app:

Write a modern, compact Python program that parses a Markdown file and renders it section-by-section colorfully on the terminal.

A "section" is any text beginning with a heading until the next heading.

- uv run talk.py script.md should parse script.md and render the first section.
- Running uv run talk.py should render the next section. And so on.
- If no further sections are found, it should say so and end.

When rendering on the terminal,

- Headings should be very prominent. Highlight H1, H2 and H3 in decreasing order of prominence. Rest can be rendered normally
- **Bold** should be prominent. _Italics_ should be mildly emphasized.
- Code blocks and
code fences
 should be colored distinctly.
- [Links](...) should be colored distinctly but the URLs can be ignored.

Use inline script dependencies. I think using rich and markdown2 would apt but you can decide.

An aside. These days, it’s easier to create small tools than search for something that exists.

The code it wrote works like this.

  1. Write a Markdown file that has my “slides”. I used this README.md.
  2. Run slide.py README.md. It shows the first section (“slide”) in README.md, colored and highlighted, and exits.
  3. I can run any other commands on my shell, e.g. uv run --with pandas,ipython ipython, and show how it works.
  4. Run slide.py again. It clears the screen and shows the next slide.

This allowed me a new kind of workflow, where the shell itself is the slides layer.

Leave a Comment

Your email address will not be published. Required fields are marked *