The Linux Rain Linux General/Gaming News, Reviews and Tutorials

Tips for tpp and patat

By Bob Mesibov, published 22/02/2017 in Tutorials


You might be surprised to learn that there are programs for running presentations in a terminal.

No, I don't mean opening PowerPoint or Impress slides one after the other, as images in a frame-buffered console. I mean presenting slides coded for the terminal, in a terminal.

Interesting idea? It seems to be, because there are (at least) 8 terminal presentation programs for Linux:

I haven't tried them all, but I've found tpp and patat to be fairly easy to use. Below are a few tips on working with these two programs.

Note that neither tpp nor patat presentation files need a filename suffix. The one argument for the tpp or patat command to start a presentation is the name of a text file, or the path to that filename if you're in another directory. The filename doesn't need a suffix, and the same presentation text file will run as pres, pres.txt, pres.pdf or pres.whateveryoulike. It makes sense, though, to name a tpp presentation with the filename suffix .tpp, or a patat presentation with the suffix .patat, so you can find the file more easily and remember what it is.

tpp

tpp is a 41 kB Ruby script written by Andreas Krennmair (author of the popular newsbeuter RSS reader) and Nico Golde, and it presents slides in ncurses. To try it out, install the latest version (currently 1.3.1) from your Linux repository. See the README that comes with tpp for full instructions on its use. Example files come with tpp, and these are also on GitHub here.

With tpp you're not stuck with the default ncurses background colours, which are black, blue, cyan, green, magenta, red, white and yellow. You can set any one of these for your presentation with the --bgcolor global option, for example

--bgcolor cyan

but tpp also has the option

--bgcolor default

which makes the background transparent, and gives it the background colour of your terminal. If your terminal itself is transparent, for example over a desktop wallpaper, that wallpaper will be the slide background:

1

According to the documentation and one of Krennmair's examples, you can run a shell command within tpp by using the "--exec" option. This doesn't work with my kernel's default settings (3.16.0, Debian 8) and I get a tpp error message on the slide: --exec disabled by default for security reasons. Use option -x to enable it. Adding option "-x" to the tpp command (as in tpp -x file) removes the error message from the slide, but the shell command following exec still isn't launched.

While it would be cool to launch a command from a presentation slide, tpp offers another way to show commands and their results. If you use the "beginshelloutput/endshelloutput" option and prefix your command with "$", then tpp prints that line character by character, as though you were typing it. The lines that follow can be the expected command output, and all of this will "shell output" be framed by dashes. Here's the example slide shown in the screenshot above; save it as file and run tpp file:

--bgcolor default
--boldon
An example of faking a command:

--beginshelloutput

$ echo -e  "aaa\nbbb\nccc"
aaa
bbb
ccc

$ echo -e  "aaa\nbbb\nccc" | tr '\n' ','
aaa,bbb,ccc

--endshelloutput
--boldoff

patat

patat is a massive (43 MB) executable written in Haskell by Jasper Van der Jeugt, and it relies on a range of Haskell libraries instead of ncurses. If you're running Debian 9 you're in luck, because there's a patat package in the repository. If like me you're running an earlier Debian base, you'll need to build patat from source. There are full instructions for that here, on the same webpage as the patat how-to.

You can't center a line of text on a slide with patat, as you can with tpp. I also haven't been able to get patat's syntax highlighting of code to work. This may be because I haven't got all of kate's KDE libraries on my Xfce setup, or it may be an issue with the code for character colouring on my Xfce terminal.

Why, then, would I use patat instead of tpp for simple text slides? Because it does tables! With column alignment! (See below.)

The default styling in patat seems to be based on Ethan Schoonover's solarized theme. Here's how a sample slide looks in my Xfce4 terminal, which I like to show yellow text on a dark green (#004400) background. (I've shrunk the terminal window to make the screenshot smaller.) Note that the comment line is ignored.

---
author: 'Bob Mesibov'
title: 'This is the title'
...

#This is a header

[comment]: # This is a comment

This is *emph text*

This is **bold text**

This is `code text`

Here is a code block:

    line of code
    another line of code
2

As you can see, patat understands simple Markdown. You can also style some of the elements of a slide in the header section of the presentation, which is started off by a line with three dashes and is closed by a line of three periods. Here I've made the header white and bold, brightened the emphasised text and changed how code is presented:

---
author: 'Bob Mesibov'
title: 'This is the title'
patat:
    theme:
        header: [vividWhite,bold]
        emph: [vividGreen]
        code: [dullBlack,onDullWhite]
        codeBlock: [dullBlack,onDullWhite]
...

#This is a header

[comment]: # This is a comment

This is *emph text*

This is **bold text**

This is `code text`

Here is a code block:

    line of code
    another line of code
3

To display tables in patat, just set the cells off with pipes and put a line of pipe-separated dashes under the header line (see code below). You can also align cell elements by putting a colon or two in the line of dashes. A colon on the left of the dashes (or no colon) means left-aligned, colons left and right mean centered, and a colon at the right means right-aligned. The table is slightly indented.

Here's a table:

| Heading 1 | Longer heading 2 | Hdg 3 |
| --- | :---: | ---: |
| Item 1 | a fairly long, centered string | 23 |
| Item 2 | also centered | 161003 |
4

Another problem I've had with patat is that if there's no title for the presentation in the header section, then patat always puts the first line of text at the very top of the terminal window. Blank lines and comment lines are respected after that first line of text, but ignored if they appear before it. The only workaround I've found is to insert a header line (with or without following blank lines) before the first line of text, and to colour the header line (styled in the header section) with the same colour as the slide background. This makes the header line invisible and drops the first line of text.

[Top image by Tom Morris, from a 2011 PowerPoint Karaoke session: speakers present a slide show chosen by other people, and have to pretend they know what the slides are about!]


About the Author

Bob Mesibov is Tasmanian, retired and a keen Linux tinkerer.

Tags: tutorial scripts tpp patat console bash presentations
blog comments powered by Disqus