Skip to content

SupportsHyperlinks() returning true on macOS default Terminal, when they do not work as expected #11

@clicktravel-james

Description

@clicktravel-james

Hi authors 👋

Happy Holidays 🎄

Issue Summary

We are developing a CLI tool and wanted to embed some links using this library. We found that the support for links is somewhat varied across the different terminal types supported by macOS. This is fine but we have had to add our own logic to work out which of these Terminal applications support links.

This is what we expected the feature SupportsHyperlinks() todo for us. Sadly on the default Terminal application that is provided with the macOS, the return value for SupportsHyperlinks() is true but the link is hidden and not clickable. The text appears in the console like all other text and you would not know it was special to any other fmt.Println() statement.

Change request

Is it possible to improve the library so that it is aware of this feature being disable in the macOS Terminal app so we can remove our simple bespoke code that is doing this logic for us?

Versions

GO Version: go version go1.21.6 darwin/arm64
Library Version: github.com/savioxavier/termlink v1.4.1
macOS version: Sonoma 14.7.1 (23H222)
Terminal version: Version 2.14 (453)

Screenshots

macOS Terminal application

Screenshot 2024-12-20 at 15 18 13

iterm2 terminal application

Screenshot 2024-12-20 at 15 18 39

VS Code

Screenshot 2024-12-20 at 15 20 14

Example simple bespoke patch implementation in our code

func isUsingATerminalWhichSupportsLinks() bool {
	termProgram := os.Getenv("TERM_PROGRAM")
	switch termProgram {
	case "iTerm.app":
		return true
	case "vscode":
		return true
	default:
		return false
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions