hyperlink static method

String hyperlink(
  1. String text,
  2. String filePath
)

Creates a terminal hyperlink using OSC 8 escape sequence. Supported by VS Code, Cursor, iTerm2, GNOME Terminal, Windows Terminal, etc. Falls back to plain text in terminals that don't support it.

Implementation

static String hyperlink(String text, String filePath) {
  final absolutePath = File(filePath).absolute.path;
  // Using BEL (\x07) instead of ST (\x1B\\) for broader terminal compatibility
  return '\x1B]8;;file://$absolutePath\x07$text\x1B]8;;\x07';
}