feat: add clickable hyperlinks for URLs in terminal output

Use OSC 8 escape sequences to make tweet and list URLs clickable
in supported terminals (iTerm2, Ghostty, Kitty, WezTerm, VS Code, etc.).

- Add hyperlink() helper function in output.ts
- Apply hyperlinks in printTweets() for tweet URLs
- Apply hyperlinks in printLists() for list URLs
- Add hyperlinks flag to OutputConfig (auto-disabled for non-TTY)
- Automatically falls back to plain text in --plain mode or when piped

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
Martin Funk
2026-01-11 11:10:34 +00:00
committed by Peter Steinberger
co-authored by Claude Opus 4.5
parent bbc90dbe08
commit 837b09fcad
4 changed files with 79 additions and 18 deletions
+3 -1
View File
@@ -4,6 +4,7 @@
import type { Command } from 'commander';
import type { CliContext } from '../cli/shared.js';
import { extractListId } from '../lib/extract-list-id.js';
import { hyperlink } from '../lib/output.js';
import type { TwitterList } from '../lib/twitter-client.js';
import { TwitterClient } from '../lib/twitter-client.js';
@@ -23,7 +24,8 @@ function printLists(lists: TwitterList[], ctx: CliContext): void {
if (list.owner) {
console.log(` ${ctx.colors.muted(`Owner: @${list.owner.username}`)}`);
}
console.log(` ${ctx.colors.accent(`https://x.com/i/lists/${list.id}`)}`);
const listUrl = `https://x.com/i/lists/${list.id}`;
console.log(` ${ctx.colors.accent(hyperlink(listUrl, listUrl, ctx.getOutput()))}`);
console.log('──────────────────────────────────────────────────');
}
}