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
@@ -7,6 +7,7 @@ import kleur from 'kleur';
import { type CookieSource, resolveCredentials } from '../lib/cookies.js';
import { extractTweetId } from '../lib/extract-tweet-id.js';
import {
hyperlink,
labelPrefix,
type OutputConfig,
resolveOutputConfigFromArgv,
@@ -323,7 +324,8 @@ export function createCliContext(normalizedArgs: string[], env: NodeJS.ProcessEn
if (tweet.createdAt) {
console.log(`${l('date')}${tweet.createdAt}`);
}
console.log(`${l('url')}https://x.com/${tweet.author.username}/status/${tweet.id}`);
const tweetUrl = `https://x.com/${tweet.author.username}/status/${tweet.id}`;
console.log(`${l('url')}${hyperlink(tweetUrl, tweetUrl, output)}`);
if (opts.showSeparator ?? true) {
console.log('─'.repeat(50));
}