TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: TableTennis, a new rubygem for printing stylish tables in your terminal

5 pointsby gurgeousabout 1 month ago

1 comment

gurgeousabout 1 month ago
This got some attention in r&#x2F;ruby so I figured I&#x27;d post it here too..<p>TableTennis is a new gem for printing stylish tables in your terminal. We&#x27;ve used ad-hoc versions of this in our data projects for years, and I decided to bite the bullet and release it as a proper gem.<p>- auto-theme to pick light or dark based on your terminal background - auto-layout to fit your terminal window - auto-format floats and dates - auto-color numeric columns - titles, row numbers, zebra stripes...<p>By far the hardest part is detecting the terminal background color so we can pick light vs dark theme for the table. This requires putting the console into raw mode and sending some magic queries. These queries are widely supported but not universal. There are some great libraries for doing this in Go &amp; Rust, but as far as I know nothing like it exists for Ruby. Check out the long comment at the bottom of this helper if you are curious:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;gurgeous&#x2F;table_tennis&#x2F;blob&#x2F;main&#x2F;lib&#x2F;table_tennis&#x2F;util&#x2F;termbg.rb">https:&#x2F;&#x2F;github.com&#x2F;gurgeous&#x2F;table_tennis&#x2F;blob&#x2F;main&#x2F;lib&#x2F;table...</a><p>As always, feedback, feature requests and contributions are welcome.