Skip to content

gurgeous/tennis

Repository files navigation

test

Tennis

tennis is a small CLI for printing stylish CSV tables in your terminal. Rows will be truncated to fit and it'll automatically pick nice colors to match your terminal. Written in Zig. Demo:

screenshot

Installation

Brew/macos

$ brew install gurgeous/tap/tennis

Linux tarball

Build from source

$ mise trust && mise install
$ zig build

Important Features

  • auto-layout to fit your terminal window
  • auto-themes to pick light or dark based on your terminal background
  • titles, row numbers...

Options

Usage: tennis [options] <FILE>

Options:
        --color <COLOR>             Turn color off and on (on|off|auto)
        --theme <THEME>             Select color theme (auto|dark|light)
    -n, --row-numbers               Turn on row numbers
    -t, --title <STRING>            Add a title to the table
    -w, --width <INT>               Set max table width in columns

Note that color defaults to on. Tennis likes to be colorful.

An Aside: Term Background

tennis uses a termbg.zig module to detect the terminal background color so it can choose the correct theme (dark or light). Detection is complicated, and I'm calling it out here because I don't think anyone has implemented this in Zig yet.

Future Work

There are many features I can add if there is demand, including zebra striping, numeric formatting, color scales, more control over column layout, etc. Other areas to explore:

  • windows support
  • use zg for string measuring and truncation of graphemes (vs codepoints)

Similar Tools

We love CSV tools and use them all the time! Here are a few that we rely on:

  • bat - syntax highlights csv files, and many others
  • csvlens & tidy viewer - great viewers for CSV files, beautiful and fun
  • qsv - filter, sort, combine, join... (a fork of xsv)
  • Terminal::Table - wonderful rubygem for pretty printing tables, great for non-hash data like confusion matrices
  • visidata - the best for poking around large files, it does everything
  • table_tennis - my own project, the basis for this one

Changelog

0.0.2 (Mar '26)

  • Initial release.

Special Thanks

  • termbg and termenv for showing how to safely detect the terminal background color. These libraries are widely used for Rust/Go, but as far as I know nothing similar exists for Zig.
  • I copied the header color themes from tabiew. Great project!