Show HN: Hntui – Hacker News 的 TUI(终端用户界面)
Show HN: Hntui – A TUI for Hacker News

原始链接: https://github.com/ahmd-sh/hntui

**hntui** 是一款简洁优雅的 Hacker News 终端用户界面(TUI)。它提供了类似 Vim 的导航、鼠标支持以及自定义主题(包括对经典 HN 视觉风格的忠实还原),带来了原生般的浏览体验。 **主要功能:** * **导航:** 可浏览全部六个 HN 信息流(Top, New, Best, Ask, Show, Jobs),并通过“已保存”列表管理帖子,数据支持跨会话持久化。 * **交互:** 全面支持键盘快捷键和鼠标操作,包括滚动页面、折叠评论树以及在浏览器中打开链接。 * **视觉:** 具备“霹雳游侠”(Knight Rider)风格的加载动画,并支持真彩色(truecolor)。 * **安装:** 推荐使用独立二进制文件安装:`curl -fsSL https://raw.githubusercontent.com/ahmd-sh/hntui/main/install.sh | sh`(无依赖项)。也可通过 `npm` 安装(需 Bun 1.2+)。 * **兼容性:** 适用于任何支持真彩色、鼠标输入和 UTF-8 的现代终端。 `hntui` 基于 OpenTUI 构建,提供了一种高性能、以键盘为中心的终端阅读方式,助你直接在终端内获取科技新闻。

开发者 `ahmd-sh` 近期发布了一款名为“Hntui”的终端用户界面(TUI),用于浏览 Hacker News。该项目基于 OpenTUI(使用 Zig 编写)和 Effect 库构建。 这一发布在 Hacker News 用户中引发了热烈讨论。一些用户认为它是赛博机(cyberdeck)等专用硬件的优秀工具,但也有人质疑其技术栈的复杂性,尤其是 Zig、TypeScript 和 React 的组合。批评者指出,与 Ratatui 等替代方案相比,该应用的内存占用较高;甚至有用户声称仅用 16 分钟就重写了一个更轻量级的版本。 尽管存在技术争论,用户们仍提供了建设性的反馈,建议增加登录和发帖等功能。总体而言,该项目既是一个实用的工具,也为关于 TUI 开发选择的技术讨论提供了一个平台。
相关文章

原文

A sleek and elegant tui for browsing one of the best tech news sources.

hntui — Hacker News in your terminal

curl -fsSL https://raw.githubusercontent.com/ahmd-sh/hntui/main/install.sh | sh
hntui
  • Browse all six HN feeds: Top, New, Best, Ask, Show, and Jobs.
  • Navigate through a post's comments.
  • Save posts for later.
  • Vim + mouse support.
  • Themes.
  • ... and a really cool Knight Rider scanner animation for loaders (⁠◕⁠ᴗ⁠◕⁠ )

Any modern terminal with truecolor, mouse support, and UTF-8 will work. I've tested it in Ghostty on MacOS. Linux/Windows is supported by OpenTUI but I haven't tried it (yet).

The prebuilt binaries have no dependencies. Installing through npm (or hacking on the code) needs Bun 1.2 or newer.

Standalone binary (recommended)

curl -fsSL https://raw.githubusercontent.com/ahmd-sh/hntui/main/install.sh | sh

Installs a self-contained binary to ~/.local/bin. You can also grab a binary for your platform directly from the releases page. Binaries cover macOS (Apple Silicon) and Linux (x64, arm64) — on an Intel Mac, use the Bun install below.

bun add -g @ahmd-sh/hntui

Or run it once without installing:

Press q (or Ctrl-C) to quit.

Checks the latest release and, for binary installs, replaces itself in place. Bun installs update with bun add -g @ahmd-sh/hntui instead (hntui update will tell you so). When a newer release exists, the status bar shows a quiet hint. hntui --version prints the installed version.

Key Action
j / ↓, k / ↑ Move cursor
gg, G Jump to first or last
Ctrl-D, Ctrl-U, PgDown, PgUp Scroll a half page
c, Enter Open the story and read its comments
h / ←, l / → Previous or next tab
Tab, Shift-Tab Cycle through tabs
1 through 6 Jump to a specific category
S Jump to the Saved list
s Save or unsave the highlighted post
o Open the story's URL in your browser
r Refresh the current feed
t Toggle theme
q, Ctrl-C Quit
Key Action
j / ↓, k / ↑ Move the comment cursor
gg, G Jump to first or last comment
Ctrl-D, Ctrl-U, PgDown, PgUp Scroll a half page
Space Collapse or expand the current subtree
Enter Open the links popup for the current comment
s Save or unsave this story
o Open the story's URL
Esc, Backspace, h / ← Back to the list
t Toggle theme
q Quit
Key Action
j, k, ↑, ↓ Move
gg, G First or last link
o, Enter Open the highlighted link
Esc, Backspace Close the popup

Context menu (right-click)

Key Action
j / ↓, k / ↑ Move
Enter Activate
Esc, Backspace Close

Most things you can do with the keyboard, you can do with a mouse too.

  • Click a tab to switch feeds.
  • Click the Y tile to refresh the current feed (or to exit a story back to its list).
  • Click any story row to select it. Click it again to open the comments.
  • Right-click a story to open a context menu with Save, Open URL, and Open Comments.
  • Click a comment's header line to collapse or expand its subtree.
  • Double-click a comment's body to open its links popup.
  • Click the story URL in the detail header to open it in your browser.
  • Click outside a popup or context menu to dismiss it.
  • Use your scroll wheel to scroll lists and comment trees.

Selecting and copying text

Because the app captures mouse events, your terminal's normal click-and-drag selection is intercepted. To select text the regular way:

  • On macOS (Terminal.app, iTerm2, WezTerm, Ghostty), hold Option while you drag, then Cmd-C.
  • On Linux (Kitty, Alacritty, WezTerm, GNOME Terminal), hold Shift while you drag, then Ctrl-Shift-C.

Press t to toggle. The dark theme is mostly black with orange accents. The light theme is faithful to news.ycombinator.com: white background, orange topbar, the familiar beige row highlight, and HN's classic grey byline text.

Press s on any story to save it. Saved posts get a small star next to the title and show up in the Saved tab on the right side of the tab strip. The list persists across sessions in ~/.config/hntui/saved.json as a small JSON file. (Config from the app's hackernuis days is migrated automatically on first run.) Press s again to remove a post from the list.

S jumps straight to the Saved list from anywhere.

git clone https://github.com/ahmd-sh/hntui.git
cd hntui
bun install
bun dev    # hot reload

Data comes from the public Hacker News Firebase API.

Pushing a v* tag triggers two workflows:

  • .github/workflows/release.yml cross-compiles standalone binaries (bun build --compile) for macOS and Linux (arm64 and x64), smoke-tests the Linux build against the live API, and attaches the tarballs to a GitHub release. This is what install.sh downloads.
  • .github/workflows/publish.yml publishes @ahmd-sh/hntui to npm via OIDC trusted publishing, with a SLSA provenance attestation linking the tarball back to the exact commit and workflow run that produced it. It skips gracefully if the version is already on npm.

To release a new version:

npm version patch   # or minor / major
git push --follow-tags
  • OpenTUI by Anomaly. The native TUI core that makes all of this possible.
  • opentui-spinner by Matt Simpson. The Knight Rider loading scanner is adapted from examples/knight-rider/utils.ts (MIT).
  • Effect for empowering the data layer under the hood.
  • Hacker News for the content and the open API.

MIT, Copyright (c) 2026 Ahmed Shaikh.

联系我们 contact @ memedata.com