Holding Cmd on OSC 8 link-text should interact with the embedded URL, not the link text
I have a script that emits some OSC 8 anchor text. The URL of this anchor is not accessible in my primary browser profile, but only in my secondary enterprise-account browser profile. So it's not helpful to just cmd+click the URL to open it — as that would open the URL in my primary profile (and then immediately redirect to a login gateway, preventing me from selecting the URL in the address bar.) I would like to copy the URL itself to the clipboard, to paste it into my secondary browser profile window myself.
With regular URL-patterned text in iTerm, holding Cmd and left- or right-clicking will first select the text of the URL, such that further interactions proceed with that selection, which generally "does the right thing." So e.g. "Copy" in the context-menu copies the URL, not because of any special behavior, but rather because it's the selected text.
But holding Cmd and left- or right-clicking OSC 8 anchor does not first select the (hidden) URL text. Rather, while there is an additional behavior of cmd+left-click opening the embedded URL, the default action for text when cmd+clicked — selecting the "word" at the cursor position — applies. This means that cmd+right-click -> Copy will actually copy that highlighted word. (Additionally, if you already had some other text selected, this doesn't happen, so Copy will actually copy the previously highlighted text instead!)
I would expect iTerm to enable interaction with OSC 8 anchor URLs in one of two ways:
-
Special-case cmd+right-click of OSC 8 anchors, and provide additional context-menu options (e.g. "Copy URL") in such cases
-
Treat the OSC 8 anchor URL as hidden zero-width text in the session (similar to what ANSI SGR 8 "Conceal" would do if implemented) such that cmd+clicking the OSC 8 anchor text would first select this hidden/zero-width text, and then react normally from there (i.e. with the same generic interaction as cmd+clicking on URL text.)
The first option is probably easier, unless you were already planning on implementing SGR 8 "Conceal" support.