-
Notifications
You must be signed in to change notification settings - Fork 689
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 file paths #1972
Comments
I would +1 this, and also say, it would be nice if this worked for URLs too. It's one of the features that I really miss after switching from iTerm 2. I thought maybe @mitchellh had an issue about this earlier this year, but I'd love to be able to cmd+click urls! |
Ghostty recently added support for OSC 8, which allows apps to embed hyperlinks. Ghostty has had for a long time auto-detection of hyperlinks shown on screen. If you hold down the control key and hover your mouse over an embedded URL you can click on them. Try using |
Here's the PR that added OSC 8 support: #1928 |
This is already implemented. Hold command on Mac and ctrl on Linux. |
Ah, OK, well must be my tmux interfering with that! You're right though, outside of tmux it works. Kapture.2024-07-19.at.10.58.21.mp4 |
@briancain tmux (and other full screen TUI apps like Vim) capture your mouse, so click events are intercepted by the application and not received by Ghostty. You can hold the Shift key to escape mouse capture. So to click on a link in tmux (or Vim, etc.), you would use Cmd+Shift+Click. |
@gpanders - fair enough! Just saying, folks coming from iterm to ghostty, tmux cmd+click still works in iterm2 land 😄 Kapture.2024-07-19.at.13.30.17.mp4At this point it's a little off topic from the original issue so I'm happy to take it to a new one |
If someone can point me to the regular expressions used by iTerm or any other terminal for these file path captures then I could add this very quickly since our URL system was built to be generic like this. |
See #2111. Automatically detecting paths via regex is very difficult to get right, but apps that support OSC 8 make that a lot easier. |
Just discovered this via hnews post. Incredible stuff everyone! I fired up ghostty and loved it instantly. The speed kicks! For me, I come from iTerm2 land and this is sadly a hard requirement as it's baked into my workflow. I recognize it's a hard problem not only on detection but allowing which program load if you want to get away from system's settings. Really hoping to see this soon! |
Cleanroom disclaimer: I've read no source code to figure this out, this is 100% from my experience using iTerm, and testing the edge cases. Roughly speaking:
The easiest way to demo this is to open iTerm and run:
edit: edit: also picks up line numbers appended to the end of a path, in the format |
Agree this is a very useful feature! I rely on it pretty much daily. I think the logic for identifying line numbers is here: |
This is how it's configured in guake on linux:
|
@mitchellh The Zed implementation of this is here: https://github.com/zed-industries/zed/blob/033726cf8713829ea5d5626e9bf86044c1dacd04/crates/editor/src/hover_links.rs#L803-L891
|
this is partially implemented by #4713 |
I believe this is implemented in #4713 and released in 1.1.0 and can be closed now. To click on a file path, hold command and click on the highlighted path. |
I can confirm that absolute file paths are clickable. Relative are not however (well, you can click the part that follows the first relative path component, which doesn't really make any sense). |
Also, it is not working if the file contains line and column references, such as:
This is e.g. what many compilers output ( |
What does the iterm implementation open your default editor via $EDITOR environment virable. |
|
I see that Cmd+click on a file name opens the file via the Mac "open" command. To me, it makes more sense that, if the $EDITOR variable is set, to open it with the configured text editor. Is anybody aware of whether there is an open issue about that, or it's in plan to use $EDITOR, etc? |
I'd also expect this to use |
The best approach would be to have a configuration entry to support both, I don't mind |
Well the problem the current regex doesn't support |
The current regex is getting unwieldy... And it's matching both too much and not enough. For example, anything that matches |
I also feel like there should be a seperate regex for urls and file urls because It just seems one regex is not match the two sorrectly. |
Just adding a reference to how it is configured in wezterm, https://wezfurlong.org/wezterm/hyperlinks.html#implicit-hyperlinks |
I am not sure if my solution fits this issue, but sometimes, the URL regex/routine doesn't work properly. I have cases when the sentence contains a URL with ':' at the end. In this case ':' is used as part of the URL when it shouldn't. This is quite typical in terminal emulation but somehow gnome-terminal recognizes this URL properly |
I'd also be super ok with a default that works for 95% of cases and allow customizing the regex and the command that get's called when you click a link. I know the goal of ghostty is to be configuration-free out of the box for 9x% of users but an optional configuration option would perhaps be helpful here. That way, we could:
|
I would love for it to also support (or allow me to write a regex that does) other protocols, and rely on the system to take action. for instance |
I think regex support would be covered by https://ghostty.org/docs/config/reference#link ? Unfortunately, it says it "can't currently be set". I don't know if there is another discussion/ticket specifically for this (I couldn't find one). In addition to supporting other protocols, in Alacritty and iTerm2, I have a regex for Jira tickets that opens them in a browser. |
any update on this? Also could you give an example how we can set the link-url or the link properties? |
…ickable-file-paths
…ickable-file-paths
@mitchellh As per #189 (comment), can you let us know if this feature request is on the "immediate" roadmap? It's the sole thing keeping me on iTerm at the moment, as it's so integral to my workflows. |
Your answer is right in the comment you linked:
Sorry, I want this feature too, but this is an all volunteer project. Your options are to patiently wait, write the code yourself, or find/hire someone to do it for your. |
In iTerm you can
cmd+click
all the valid file paths to open it inside the configured application for that file type. I use that functionality quite a lot, for example when compiling TypeScript to quickly open the files with issues.Might be related to #968.
iterm-clickable-files.mp4
ghostty-clickable-files.mp4
The text was updated successfully, but these errors were encountered: