From 88cc49e831fa40d9a4e9f729c9cc468b2feaab74 Mon Sep 17 00:00:00 2001 From: Jens Rottiers Date: Wed, 28 Jan 2026 20:02:53 +0100 Subject: [PATCH] Added support for Windows and Linux and changed a typo in the README.md --- README.md | 2 +- src/index.ts | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b1e5336..3299b3f 100644 --- a/README.md +++ b/README.md @@ -210,4 +210,4 @@ This permanently disables telemetry. Your preference is stored locally at `~/.co ## Credits -Built with [OpenTUI](https://github.com/anthropics/opentui) +Built with [OpenTUI](https://github.com/anomalyco/opentui) diff --git a/src/index.ts b/src/index.ts index 6c3f47d..0f2f1d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,28 @@ #!/usr/bin/env bun import { createCliRenderer } from "@opentui/core"; import { exec } from "child_process"; +import { platform } from "os"; import { HackerNewsApp } from "./app"; import { checkForUpdates, currentVersion } from "./version"; import { setTelemetryEnabled } from "./config"; import * as telemetry from "./telemetry"; +import { open } from "fs"; const COLORS = { bg: "#1a1a1a", }; +function openUrl(url: string): void { + const os = platform(); + if (os === "darwin") { + exec(`open "${url}"`); + } else if (os === "win32") { + exec(`start "" "${url}"`); + } else { + exec(`xdg-open "${url}"`); + } +} + function parseArgs(): { storyId?: number } { const args = process.argv.slice(2); let storyId: number | undefined; @@ -64,9 +77,7 @@ async function main() { }); const app = new HackerNewsApp(renderer, { - onOpenUrl: (url) => { - exec(`open "${url}"`); - }, + onOpenUrl: openUrl, onExit: async () => { await telemetry.flushSync(); renderer.destroy();