Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex Hyperlink Matching and simplified opening #823

Closed
oxo42 opened this issue Nov 23, 2018 · 10 comments
Closed

Regex Hyperlink Matching and simplified opening #823

oxo42 opened this issue Nov 23, 2018 · 10 comments

Comments

@oxo42
Copy link

oxo42 commented Nov 23, 2018

I would like to be able to setup a regex with capture groups that can be turned into a hyperlink. An example is if the following text is on the terminal

See task T1234 for more details

I'd like to match it against T(\d+) and when I Ctrl+Click, it should open up the URL http://my.task.tracker.com/t=$1.

The issues #132 and #173 seem to be a good base to work off and they mention this pull request.

I think termmouse.c is the place to start looking, but can't figure it out. Could I get a hint?

@mintty
Copy link
Owner

mintty commented Nov 23, 2018

Unclear; in what sense would you match against the regex, i.e. where would the regex come from?
Considering that URLs can be formed in lots of ways, how should the match be mapped to a URL?
This sounds like way beyond what a terminal can reasonably provide.

@oxo42
Copy link
Author

oxo42 commented Nov 24, 2018

I'm explaining myself poorly, sorry.

Currently in mintty, when there is a hyperlink on the screen I Ctrl+click it and it opens a browser. Somewhere in mintty, there must be some code that registers http://stuff as clickable and somewhere else must say "Open that with the system browser" when it is clicked.

What I want to do is have some code that registers T(\d+) as clickable, then when it is clicked, turn it into a URL.

On a similar note, urxvt has matchers and terminator has plugins that will do this

@mintty
Copy link
Owner

mintty commented Nov 24, 2018

Link detection is hard-coded and it always opens the plain link, not any substituted derivation.
Also I do not really see a strong use case for such transformation.
And there is no intent to add such complex configuration or even a plugin framework to mintty, sorry.

@mintty
Copy link
Owner

mintty commented Nov 24, 2018

On the other hand, mintty has user-defined commands already. Check that out, I'd imagine you can achieve with it what you want.

@mintty
Copy link
Owner

mintty commented Nov 25, 2018

I've added this example to the manual page, as a pattern:

UserCommands=google:/bin/cygstart https://www.google.de/search?q="$MINTTY_SELECT"

Then select your text, Ctrl+right-click, and choose menu item "google".

@mintty mintty closed this as completed Nov 25, 2018
@oxo42
Copy link
Author

oxo42 commented Nov 27, 2018

I'm trying to cut down on the number of steps to open up the web browser. For my case I know that T1234 should to to https://tasks.com/q=1234 and I don't want to have to select something from a menu. That's where the smart matching comes in.

Thanks for your time

@mintty
Copy link
Owner

mintty commented Nov 27, 2018

We're talking about two things here:

  • Magic selection according to configured matching rules. As this is currently hard-coded (see the group of sel_spread functions in termmouse.c), it would mean a lot of fiddly work...
  • How to open selected text. If you'd be contented with manually selecting your match for now, this would be the easier part. I can image to assign the opening function to a mouse click or key press (like key shortcuts can be configured already, see option KeyFunctions).

@mintty mintty reopened this Nov 27, 2018
@mintty mintty changed the title Regex Hyperlink Matching Regex Hyperlink Matching and simplified opening Nov 27, 2018
@mintty
Copy link
Owner

mintty commented Jan 22, 2019

As an alternative suggestion, mintty will support the OSC 8 protocol to set hyperlink attributes and explicitly mark text parts to open certain links. See Hyperlinks in terminal emulators for a discussion.

@mintty
Copy link
Owner

mintty commented Mar 14, 2019

Released 2.9.7 with hyperlink support.

@mintty
Copy link
Owner

mintty commented Apr 29, 2019

Assuming that the explicit hyperlink feature can also achieve the desired behaviour (although it requires a cooperating application), I'm closing the issue for now.

@mintty mintty closed this as completed Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants