Scenario: Add support for hyperlinks
This is the the megathread for tracking all the remaining work that needs to be done for hyperlink support in Terminal.
"Soon" Timeframe
- [x] Original issue: #204 -> added in #7251
- [x] Allow
file://URIs -> added in #7526 - [ ] #7562 Allow other URI schemes
- [x] Render hyperlinks differently from regular text in Terminal -> added in #7420
- [x] Hover underline text that have the same hyperlink ID and display the URI -> added in #7420
- [x] Display a content dialog box for URIs we cannot parse/schemes we do not support -> added in #7523
- [x] https://github.com/microsoft/terminal/issues/574 Add support for Terminal to auto-detect hyperlinks -> added in #7691
- [ ] #7563 Switch the pointer to the 👆 icon when we're hovering a link (in the clickable state, like with ctrl pressed)
- [ ]
VtEngine::_SetHyperlinkusesfmt::formatto render the hyperlinks, and it should really use_WriteFormattedString - [ ] #7564 Hook up hyperlinks to conhost (rendering + clicking)
- [ ] #7565 Make sure hyperlinks are included in HTML copy
- [x] #8123 Only underline hyperlinks on hover -> added in #8148
- [ ] ~Controlling tooltip delay for URLs #8242~
- Abandoned, platform limitation
- [x] ~Add a setting to disable auto detection of links (in PR #8239)~
- Abandoned, we're not sure anyone actually ever wanted this
- [ ] Links/URLs get offset when certain unicode characters are printed #8709
- [x] url detection not working with tmux #9117
- [ ] Keyboard navigation of clickable link #6649
- [ ] #11901
Backlog
- [ ] Add a setting to configure the regex used to detect patterns
- [ ] Allow "hyperlink" matching for arbitrary patterns and adding custom handlers #8849
- Theoretically, this could supersede #7562
- Should be self-consistent with #8294
- [ ] Control the styling of hyperlinks - attributes used for autodetected hyperlinks, and then different attributes for hovered ones #8294
- [ ] Feature Request: link generation for files + other data types #2671
References
- This VsCode issue has an enormous set of references to improvements they've made: https://github.com/microsoft/vscode/issues/172084
Proposed order of attack:
- Hover tooltip
- Rendering -- possibly simple rendering w/ a new underline style for me?
- Take a break, regroup, think about the design for autodetection
- (possibly work on other things in the meantime)
- Autodetection
Hey so hover tooltip might be hard - we can't embed a webview, so doing something like

Might be especially hard. But we could start with a TeachingTip sytle one for now

Unless we could somehow pre-render a web page to an image and display that in the tooltip. Or use something like the "social" image from github (though I haven't the damndest clue how that works.)
Maybe we should just start with
Open [web page | file]:
{url}
in the tooltip
Yeah i definitely think tooltip and “the link preview from the video” are different workitems that we should tackle separately :)
If you have to have a "link preview", I'd recommend something really basic based on the page meta data (like the meta title and description, and maybe a favicon and/or og:image). But as cool as this might seem, I don't think it's practical for a hover effect given the delay needed to download and render these things (unless you're pre-rendering the previews, which sounds like a really bad idea).
Which brings me to the main problem. Even if you're only connecting to the site on hover, that still seems inadvisable. When I'm using a terminal I really wouldn't expect it to be making internet connections without my consent. So this feature would definitely have to be optional, and arguably I think should be off by default.
I'm possibly a little biased here, because my internet connection is metered to a certain extent. But even if that weren't the case, would most people be comfortable with their terminal downloading unknown webpages in the background?
Yeah, I definitely don't think that "fetch any link I hover over" is something we should ship in core or opt-in by default. It makes for a really compelling video because it shows how modern and flashy we are, but it's too much of a disclosure and safety risk to put right into our project.
- Allow
mailto:URIs
Would this be RFC conforming 😒 mailto: URL, or 😍 mailto: URL that allows multiple email addresses?
Generally, "whatever type of thing is supported by the registered protocol handler" ;P
I don't know whether this has been considered already, but when doing a rich-text copy of the terminal buffer the hyperlinks should probably be preserved on paste
Thanks @jantari! Just added that to the main scenario body.
I just built the latest commit, but it can't parse an url, you have to use the escape sequences. Is this use case planned:
echo 'Hello from Windows Terminal: https://github.com/microsoft/terminal/'
And then click on the link and it opens?
@giggio er..



I don't just say these things for fun 😉 (edit: this was intended to be read as "funny", not "wow Dustin's a jerk" (but I get it!))
I had seen that comment, I was just not sure that this is what it meant, thanks for the clarification, Dustin! And good thing you explained, so I could see it as funny. ;)
So, if I understand correctly, we don't have yet an issue tracking this item (auto-detection) specifically?
@giggio There's a lot of discussion about how to do autodetection in the comments on https://github.com/microsoft/terminal/issues/574 :smile: so we're somewhat treating that issue as canonical.
Question about url detection in 1.5.3142.
Works great in the terminal, but not inside vi. Is the app doing something special to disable this, or a different mode that url detection does not work with? I was really hoping to be able to Ctrl-Click all those documentation links in code comments.

So, Vim (if that's your vi implementation of choice) enables "mouse mode" -- it lets you select text and navigate the document with your mouse. You can either turn off mouse mode (:set mouse=) or temporarily suppress it by holding down Shift.
(This is also the reason that you cannot select text using the terminal when Vim is running.)
Thanks for the information, "mouse mode" was not turned on by default for me in:
- WSL, Ubuntu 20.04 where I tested vim 8.1
- Windows, where I use neovim v0.5.0-558-g6d1404faf
and links worked OOTB, but I could enable it on either with :set mouse=a and not only did it exhibit the behavior you described but I also learned about mouse-mode today, thanks!
There's no solid way to detect the version of the Windows Terminal (and this feature) by an application as of now. One more use case to support #1040 .
One way is to trigger wt -v as wt is available in the Path but the again, it shows up an alert rather than just printing it. (Any reasons it does that?)
any reasons
About a hundred. The rationale for this spec explains why. https://github.com/microsoft/terminal/blob/dev/duhowett/spec/console-allocation/doc/specs/%237335%20-%20Console%20Allocation%20Policy.md#abstract
About a hundred. The rationale for this spec explains why. https://github.com/microsoft/terminal/blob/dev/duhowett/spec/console-allocation/doc/specs/%237335%20-%20Console%20Allocation%20Policy.md#abstract
Ah I see. Thanks for the clarification. Waiting for 1040 to get resolved :).
Edit: I don't understand the abstract but I get there are valid reasons.
I was wondering if there was any plans to support data: URIs?
This could be used to embed a (very small) image or just some plain text that would appear, most likely in a popup.
I saw #6747, which suggest support for parsing them is planned for settings.json icons.
There is some info about data: in terminals here: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#gistcomment-2192652
Is there a way to change to modifier key for a link press? I have grown accustomed to using ALT. I couldn't find anything in the documentation, so it would be nice to have this as a keybind setting if it does not exist already.
Is there a way to change to modifier key for a link press?
No, the Ctrl+click combination is hardcoded here:
https://github.com/microsoft/terminal/blob/9c4950cb32a06b3ba448d10371c7f6977d9d0090/src/cascadia/TerminalControl/TermControl.cpp#L1284-L1288 https://github.com/microsoft/terminal/blob/b140299e501e961f09226eba7e023db9b7cdb393/src/cascadia/TerminalControl/Resources/en-US/Resources.resw#L178-L180
If https://github.com/microsoft/terminal/issues/1553 were implemented, then users would be able to change the modifier, I think.
I have Windows Terminal 1.5.10271.0 installed, and it looks like Ctrl+Click on http://127.0.0.1:5000 actually already works (which is amazing!) - which release was this made available in? (https://github.com/microsoft/terminal/releases does not seem to contain anything specific about this). Sorry if this is the wrong issue.

[1] I know that it is in Windows Terminal Preview v1.5.3142.0 but it doesn't seem to be in the regular Winodws Terminal release notes.
This came out in 1.5!

ftp:// ... I get underlining and a popup "Ctrl+click" tip but can't follow it.
mailto:// ... nothing.
What's the plan? Thanks.
to be fair, mailto isn’t traditionally followed by // as it does not designate a path. We have issues tracking both “let me customize the URL regex” and “expand protocol support.”
So that’s the plan.
@vefatica, in v1.7.572.0, TerminalPage::_IsUriSupported allows only http, https, and file. Other URI schemes have been discussed in https://github.com/microsoft/terminal/issues/7562.
What about ftp://? ... not supported? Yet it gets underlined and a popup tip.
I can't remember way back but in recent decades I've always used mailto://. ShellExecuteEx doesn't mind
According to https://github.com/microsoft/terminal/pull/7691#discussion_r513595391, ftp: hyperlinks were going to be unblocked "shortly"; but almost five months have passed already. The regex in v1.7.572.0: https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalCore/Terminal.cpp#L87