Allow "hyperlink" matching for arbitrary patterns and adding custom handlers #12141

Open
opened 2026-01-31 03:07:18 +00:00 by claunia · 16 comments
Owner

Originally created by @mikemaccana on GitHub (Jan 22, 2021).

Description of the new feature/enhancement

A lot of developer tools print errors in:

dir/dir/filename:lineNumber:columnNumber

format. For example:

image

Terminal should make these clickable.

Proposed technical implementation details (optional)

Leverage any relevant bits about how http links work in the current version of Terminal.

Originally created by @mikemaccana on GitHub (Jan 22, 2021). # Description of the new feature/enhancement A lot of developer tools print errors in: ``` dir/dir/filename:lineNumber:columnNumber ``` format. For example: ![image](https://user-images.githubusercontent.com/172594/105504686-f7277800-5cbf-11eb-9733-7388c9c02b87.png) Terminal should make these clickable. # Proposed technical implementation details (optional) Leverage any relevant bits about how http links work in the current version of Terminal.
claunia added the Issue-FeatureArea-SettingsProduct-TerminalArea-TerminalControl labels 2026-01-31 03:07:19 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jan 22, 2021):

How would that work though? Do editors have any sort of unified way of requesting "please open this file, to this row/column"? Because I'm pretty sure they don't. VsCode might have one way, emacs another, vim a third - but I'm not sure there's any way for the terminal to know which program is the user's editor for a given filetype.

Plus like, if we ShellExecute a .py file, isn't the default behavior to run the file with the python interpreter? So that's even less likely to work!

I think VSCode's integrated terminal gets away with this because they know the editor is VsCode, and they know exactly how to tell themself how to open a file to a given row/column.

If there's a way of doing this that's supposed to be standard across editors, I'm happy to throw our weight behind it. But I'm not sure how feasible this request is without some sort of standard way of doing this.

@zadjii-msft commented on GitHub (Jan 22, 2021): How would that work though? Do editors have any sort of unified way of requesting "please open this file, to this row/column"? Because I'm pretty sure they don't. VsCode might have one way, emacs another, vim a third - but I'm not sure there's any way for the terminal to know which program is the user's editor for a given filetype. Plus like, if we `ShellExecute` a `.py` file, isn't the default behavior to run the file with the python interpreter? So that's even _less_ likely to work! I think VSCode's integrated terminal gets away with this because they _know_ the editor is VsCode, and they know exactly how to tell themself how to open a file to a given row/column. If there's a way of doing this that's supposed to be standard across editors, I'm happy to throw our weight behind it. But I'm not sure how feasible this request is without some sort of standard way of doing this.
Author
Owner

@ghost commented on GitHub (Jan 26, 2021):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Jan 26, 2021): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Jan 26, 2021):

Do editors have any sort of unified way of requesting "please open this file, to this row/column"?

Nano, vim, emacs (or emacsclient), and less support +42 file for opening file and selecting line 42. I don't think there is a common syntax for column numbers in argv.

@KalleOlaviNiemitalo commented on GitHub (Jan 26, 2021): > Do editors have any sort of unified way of requesting "please open this file, to this row/column"? Nano, vim, emacs (or emacsclient), and less support `+42` `file` for opening `file` and selecting line 42. I don't think there is a common syntax for column numbers in argv.
Author
Owner

@mikemaccana commented on GitHub (Jan 26, 2021):

How would that work though?

As a vscode user

Open file:lineNumbers in editor
Editor command. $FILE is the file name, $COLUMN is the column name
[ code.exe --goto "$FILE:$LINE" ]

As a vi user

Open file:lineNumbers in editor
Editor command. $FILE is the file name, $COLUMN is the column name
[ vi $FILE +$LINE ]

@mikemaccana commented on GitHub (Jan 26, 2021): > How would that work though? ## As a vscode user > ✅ Open file:lineNumbers in editor > Editor command. $FILE is the file name, $COLUMN is the column name > [ `code.exe --goto "$FILE:$LINE"` ] ## As a vi user > ✅ Open file:lineNumbers in editor > Editor command. $FILE is the file name, $COLUMN is the column name > [ `vi $FILE +$LINE` ]
Author
Owner

@DHowett commented on GitHub (Jan 26, 2021):

This is just a specific case of #8902 (which somebody just filed!). We should consolidate.

@DHowett commented on GitHub (Jan 26, 2021): This is just a specific case of #8902 (which somebody just filed!). We should consolidate.
Author
Owner

@zadjii-msft commented on GitHub (Jan 26, 2021):

Okay, I'll work on consolidating this with 8902, and comments we've mentioned elsewhere.

@zadjii-msft commented on GitHub (Jan 26, 2021): Okay, I'll work on consolidating this with 8902, and comments we've mentioned elsewhere.
Author
Owner

@mikemaccana commented on GitHub (Jan 26, 2021):

Thanks!

@mikemaccana commented on GitHub (Jan 26, 2021): Thanks!
Author
Owner

@zadjii-msft commented on GitHub (Jan 26, 2021):

And what about support editor:// protocol handler?
aik099/PhpStormProtocol

image


As of Windows Terminal Preview 1.4 (I think) you can Ctrl+click on text that matches a URL and it will open in a browser. This feature request would be to match on certain text and turn that into a clickable link using some of the text as a parameter.

Example

Let's say the following is on the terminal, from the output of git log

Fixes issue in T1234

I would like to setup a regex \b(T\d+)\b and when I Ctrl+click on T1234, open up https://example.com/tasks/T1234.

I would like this to be configured in settings.json something like

"arbitrarylinks": [
    {
        "pattern": "\\b(T\\d+)\\b",
        "link": "https://example.com/tasks/$1"
    }
]

So lets say we wanted to solve both these cases. What we need is a way to specify:

  • I want to match an arbitrary pattern of text in the Terminal, and
  • When I click on such a pattern, what do we do?
    • Right now, we just ShellExecute the hyperlink.
    • We need to also be able to ShellExecute links that users specify, with contents from the match
    • We also need to be able to execute arbitrary executables that the user has specified, again using contents from the match

So we couldn't just do this automatically for all editors in one unified fashion, unfortunately. But we could allow users to add config for their specific editor.

@zadjii-msft commented on GitHub (Jan 26, 2021): > And what about support `editor://` protocol handler? > [aik099/PhpStormProtocol](https://github.com/aik099/PhpStormProtocol) > > ![image](https://user-images.githubusercontent.com/177340/104156935-695bab00-53ea-11eb-97b4-2dc1a0e8cc0f.png) <hr> > As of Windows Terminal Preview 1.4 (I think) you can Ctrl+click on text that matches a URL and it will open in a browser. This feature request would be to match on certain text and turn that into a clickable link using some of the text as a parameter. > > ## Example > Let's say the following is on the terminal, from the output of `git log` > > ``` > Fixes issue in T1234 > ``` > > I would like to setup a regex `\b(T\d+)\b` and when I Ctrl+click on `T1234`, open up `https://example.com/tasks/T1234`. > > I would like this to be configured in `settings.json` something like > > ``` > "arbitrarylinks": [ > { > "pattern": "\\b(T\\d+)\\b", > "link": "https://example.com/tasks/$1" > } > ] > ``` > <hr> So lets say we wanted to solve both these cases. What we need is a way to specify: * I want to match an arbitrary pattern of text in the Terminal, and * When I click on such a pattern, what do we do? - Right now, we just `ShellExecute` the hyperlink. - We need to also be able to `ShellExecute` links that users specify, with contents from the match - We also need to be able to execute arbitrary executables that the user has specified, again using contents from the match So we couldn't just do this automatically for all editors in one unified fashion, unfortunately. But we could allow users to add config for their specific editor.
Author
Owner

@DHowett commented on GitHub (Jan 28, 2021):

This could also be an extension point. /cc @zadjii-msft triaged into backlog.

@DHowett commented on GitHub (Jan 28, 2021): This could also be an extension point. /cc @zadjii-msft triaged into backlog.
Author
Owner

@stinos commented on GitHub (Mar 24, 2021):

How would that work though?

Could have a look at how ConEmu does it: supply a bunch of 'macros' which are fed into a custom command and replaced there. Activated with Ctrl key but that's minor. See https://conemu.github.io/en/SettingsHighlight.html.

This is the only reason I'm still not on Terminal fulltime: it's not interesting to have to manually copy/paste file/line from the terminal to the editor.

@stinos commented on GitHub (Mar 24, 2021): > How would that work though? Could have a look at how ConEmu does it: supply a bunch of 'macros' which are fed into a custom command and replaced there. Activated with Ctrl key but that's minor. See https://conemu.github.io/en/SettingsHighlight.html. This is the only reason I'm still not on Terminal fulltime: it's not interesting to have to manually copy/paste file/line from the terminal to the editor.
Author
Owner

@Klaster1 commented on GitHub (Jan 30, 2024):

Any updates on this? Not baing able to click on file paths in output like in ConEmu is a huge deal breaker, I do this all the time while working with tests and TypeScript.

@Klaster1 commented on GitHub (Jan 30, 2024): Any updates on this? Not baing able to click on file paths in output like in ConEmu is a huge deal breaker, I do this all the time while working with tests and TypeScript.
Author
Owner

@zadjii-msft commented on GitHub (Jan 30, 2024):

Nothing since I posted the spec draft in #15700. Alas, been too busy with other priorities to loop back on that one.

From that spec:

A similar request from [#8849] that should also be captured. People want the
ability to configure the regexes that are used for turning text into clickable
links. Currently, we only match on a predefined set
into clickable text.

// I did not test these regexes
{
    "match": "(^(.+)\\/([^\\/]+)$):(\\d):(\\d)",
    "action": "clickableLink",
    "target": "code.exe --goto \"${match[1]}:${match[2]}\""
},
{
    "match": "git push --set-upstream origin ([^\\w]*)",
    "action": "clickableLink",
    "target": "vi \"${match[1]}\" +${match[2]}\""
},
{
    "match": "\\b(T\\d+)\\b",
    "action": "clickableLink",
    "target": "https://example.com/tasks/${match[1]}"
},
@zadjii-msft commented on GitHub (Jan 30, 2024): Nothing since I posted the spec draft in #15700. Alas, been too busy with other priorities to loop back on that one. From that spec: > ### Turn text into clickable links > > A similar request from [#8849] that should also be captured. People want the > ability to configure the regexes that are used for turning text into clickable > links. Currently, we only match on a predefined set > into clickable text. > > ```jsonc > // I did not test these regexes > { > "match": "(^(.+)\\/([^\\/]+)$):(\\d):(\\d)", > "action": "clickableLink", > "target": "code.exe --goto \"${match[1]}:${match[2]}\"" > }, > { > "match": "git push --set-upstream origin ([^\\w]*)", > "action": "clickableLink", > "target": "vi \"${match[1]}\" +${match[2]}\"" > }, > { > "match": "\\b(T\\d+)\\b", > "action": "clickableLink", > "target": "https://example.com/tasks/${match[1]}" > }, > ``` >
Author
Owner

@trajano commented on GitHub (May 14, 2024):

I'd also like a simple pattern to translate the SSH azure devops links to HTTP equivalents.

e.g. ssh.dev.azure.com:v3/ORG/PROJ/REPO to https://dev.azure.com/ORG/PROJ/_git/REPO

@trajano commented on GitHub (May 14, 2024): I'd also like a simple pattern to translate the SSH azure devops links to HTTP equivalents. e.g. `ssh.dev.azure.com:v3/ORG/PROJ/REPO` to `https://dev.azure.com/ORG/PROJ/_git/REPO`
Author
Owner

@AdrianoCahete commented on GitHub (Aug 6, 2025):

Also, I have different browser for different project/companies. I want to, when the folder is x or the link is y.

Example:

https://github.com/microsoft/terminal/issues/9491 says that, but was closed pointing to that as dup.

@AdrianoCahete commented on GitHub (Aug 6, 2025): Also, I have different browser for different project/companies. I want to, when the folder is x or the link is y. Example: - folder is "d:\projects\company_1" and/or link is "https://git.company1.com/" to be opened in Edge - folder is "d:\projects\project_2" and/or link is "https://github.com/adrianocahete/project2", to be opened in Firefox https://github.com/microsoft/terminal/issues/9491 says that, but was closed pointing to that as dup.
Author
Owner

@inoyakaigor commented on GitHub (Aug 6, 2025):

@AdrianoCahete when I was on Macos I solved same problen with links with third-party program. I think you also can try https://github.com/nref/BrowseRouter or https://github.com/Cikappa2904/BrowserChooser

@inoyakaigor commented on GitHub (Aug 6, 2025): @AdrianoCahete when I was on Macos I solved same problen with links with third-party program. I think you also can try https://github.com/nref/BrowseRouter or https://github.com/Cikappa2904/BrowserChooser
Author
Owner

@trajano commented on GitHub (Aug 11, 2025):

@AdrianoCahete when I was on Macos I solved same problen with links with third-party program. I think you also can try https://github.com/nref/BrowseRouter or https://github.com/Cikappa2904/BrowserChooser

Thanks I eventually settled on Browser Tamer after researching from your links. Its free and has a GUI. Doesn't have a macOS version, but then I don't think I'd be using Windows Terminal on macOS anytime soon.

@trajano commented on GitHub (Aug 11, 2025): > [@AdrianoCahete](https://github.com/AdrianoCahete) when I was on Macos I solved same problen with links with third-party program. I think you also can try https://github.com/nref/BrowseRouter or https://github.com/Cikappa2904/BrowserChooser Thanks I eventually settled on [Browser Tamer](https://github.com/aloneguid/bt) after researching from your links. Its free and has a GUI. Doesn't have a macOS version, but then I don't think I'd be using Windows Terminal on macOS anytime soon.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12141