Skip to content

gh stack: print full URL to stdout when terminal doesn't support OSC8 hyperlinks #183

Description

@skarim

Summary

The gh stack CLI currently emits OSC 8 hyperlinks. Many terminals (notably tmux by default and some default macOS terminals) do not support OSC 8, so the clickable hyperlink is not usable. When the terminal doesn't support OSC 8 the CLI simply omits a plain URL and the user cannot easily copy the destination.

Steps to reproduce

  1. Run gh stack in a terminal that does not support OSC 8 (e.g., a tmux session without OSC8 enabled, or certain macOS Terminal configurations).
  2. Observe that the output contains an OSC 8 hyperlink that isn't recognized by the terminal and no full URL is printed.

Actual behavior

The CLI outputs an OSC 8 hyperlink only. In terminals that do not support OSC 8 the link is not usable and no fallback (full URL) is printed.

Expected behavior

When OSC 8 is not supported by the terminal, gh stack should print the full URL to stdout as a fallback so users can copy/paste it. Alternatively (or additionally), consider providing a flag to force plain URLs (e.g., --no-osc8) or detect support and emit both (OSC 8 when supported, full URL when not).

Implementation notes / reference

The code that constructs the link appears to be here:

// PRLink formats a PR number as a clickable, underlined terminal hyperlink.
// Falls back to plain "#N" when color is disabled.
func (c *Config) PRLink(number int, url string) string {
label := fmt.Sprintf("#%d", number)
if c.Terminal.IsColorEnabled() {
if url != "" {
// OSC 8 hyperlink
label = fmt.Sprintf("\033]8;;%s\033\\%s\033]8;;\033\\", url, label)
}
// Underline
label = fmt.Sprintf("\033[4m%s\033[24m", label)
}
return label
}

Possible approaches:

  • Detect OSC 8 support and print the full URL when unsupported.
  • Add a CLI flag (for example --no-osc8) to force plain URLs for environments where OSC 8 is known to be unsupported (tmux users, CI, etc.).

Rationale

This would make the CLI more robust across environments and improve usability for users on tmux and other terminals that do not support OSC 8 hyperlinks out of the box.

No additional logs or configuration required.

View original Slack conversation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions