TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

5 点作者 gurgeous22 天前

1 comment

gurgeous22 天前
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.