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

Clickable URLs #29

Closed
phinze opened this issue Nov 14, 2022 · 14 comments · Fixed by #968
Closed

Clickable URLs #29

phinze opened this issue Nov 14, 2022 · 14 comments · Fixed by #968
Labels

Comments

@phinze
Copy link
Collaborator

phinze commented Nov 14, 2022

It's convenient to be able to click a link in the terminal instead of having to copy paste it.

Sibling project behavior:

  • iTerm2 - Links are clickable while holding cmd.
  • Alacritty - Links are clickable by default.
  • Kitty - Links are clickable by default.
@mitchellh
Copy link
Contributor

Looking at other terminals, it looks like the ones I like do this using a more generic "match regexp => associate action" system. I like that idea, but it makes this feature request quite large! Its still very important to do. So thinking out loud (I haven't looked at how others implement it, just how they configure it):

I'd probably implement this in the renderer thread. It is far too expensive to be running regular expressions on terminal input on the hot path of updating terminal state. Instead, we should probably just process the regular expressions on visible text that happens relatively infrequently in the renderer (60 to 150 Hz).

This will probably also necessitate the first time where the renderer has to be able to communicate back to the windowing thread because it will have to communicate where the clickable zones are and what action they correspond to. We have good inter-thread messaging systems in place and the windowing thread already has a mailbox so this won't be a big deal.

Likewise, once the window is aware of these clickable areas, it'll have to send messages back to the rendering thread for when they're hovered so that hover-styling can be applied. We already have a mechanism for this, as well.

@almonk
Copy link
Collaborator

almonk commented Nov 21, 2022

@mitchellh if this functionality only worked while cmd was held (like iTerm), could you parse the visible text only when the key modifier is held (rather than always happening on render)

@mitchellh
Copy link
Contributor

@mitchellh if this functionality only worked while cmd was held (like iTerm), could you parse the visible text only when the key modifier is held (rather than always happening on render)

We could, not sure if the performance at that point will matter though. Typically, the renderer is not constrained and is able to always maintain at least 60 fps with a lot of idle time in the middle.

@mitchellh
Copy link
Contributor

Just noting from #383 that this should include support for OSC 8.

@nektro
Copy link
Collaborator

nektro commented Sep 2, 2023

I've used this pattern in the past to great effect https://github.com/nektro/mantle/blob/db5c55e/www/chat/js/x/x-msg-pane.js#L40

@rockorager
Copy link
Collaborator

rockorager commented Sep 28, 2023

Throwing in my two cents here. Clickable is a must, but it would be extra cool to also have hints for those less mouse-inclined. Here's how foot does it. Default bind is Ctrl+Shift+O, then you press the letter of the hint and it opens in your configured mime handler.

1695932557.mp4

@gpanders
Copy link
Member

gpanders commented Sep 29, 2023

Kitty, Alacritty, and Wezterm all have that feature too. It's very nice, I missed it when using iTerm.

@andrewrk
Copy link
Collaborator

Sibling project behavior:

  • xfce4-terminal - Links are clickable while holding ctrl.

@slonik-az
Copy link
Collaborator

slonik-az commented Nov 14, 2023

Why limit to URLs? When I get zig compilation error in iTerm I can cmd-click on the foo.zig:42 and iTerm makes vscode open the file at the offending line. Very ergonomic.

@mitchellh
Copy link
Contributor

Why limit to URLs? When I get zig compilation error in iTerm I can cmd-click on the foo.zig:42 and iTerm makes vscode open the file at the specified line. Very ergonomic.

I have no plans to limit this to URLs! See my original response, where I describe my desire for a generalized system.

@mitchellh
Copy link
Contributor

A PR is now up with initial URL support #968. I plan to follow up with improvements in follow-up PRs. What is/isn't supported is clear in the PR body.

@xatier
Copy link

xatier commented Jan 2, 2025

I would deeply appreciate it if we can support the URxvt style extensions here, such as hotkey-based URL selection, etc: https://github.com/xyb3rt/urxvt-perls

@peterschmidt85
Copy link

@mitchellh
What is the status of this? I ran VSCode and its URL is not clickable

Image

@janpfeifer
Copy link

I also just switched to ghostty (from ptyxis and tilix), and this is the only feature I'm missing. Looking forward to this 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.