kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
22.14k stars 907 forks source link

Click on path to open in Editor #7368

Closed brandondrew closed 3 weeks ago

brandondrew commented 3 weeks ago

The feature I miss most from iTerm is the ability to ⌘-click on a path to open it in my editor. iTerm was extremely configurable in how it handled this, but just the simplest case of opening file paths in the default OS editor (or $VISUAL or $EDITOR) would be a great improvement. I'm surprised I could not find anything about this in the "Editor Integration" section of the web site.

For me the preferred editor would be Zed, but of course the feature should ideally support any editor the user wants to use.

kovidgoyal commented 3 weeks ago

See https://sw.kovidgoyal.net/kitty/open_actions/

brandondrew commented 3 weeks ago

Thanks for the link. It doesn't appear to be able to do what I'm looking for, however, because I'm looking for the ability to click on plain file paths, rather than specially-formed hyperlinks. I don't wan't to have to use a special version of ls, and in fact I don't want to use ls at all. I am looking for a way to make all paths appearing in a Kitty window to be clickable (with a modifier key).

For example, in the output of a Rails stack trace there will be many file paths. I want to make all of the file paths clickable with just the press of a modifier key, and I don't want to have to patch Rails (and everything else which puts out file paths) to make it put out specially-formed hyperlinks.

Since the page you linked to discusses "hyperlinks", it would appear to me that these must be generated by a tool that is specially forming them in order to be used in Kitty, and for them to open an editor. And the fact gls example further supports this interpretation.

This example, however, looked at first like it might do what I want, but it didn't work when I tested it:

# Open text files without fragments in the editor
protocol file
mime text/*
action launch --type=os-window $EDITOR $FILE_PATH

If it is possible to accomplish what I am describing, can you give me the missing details?

kovidgoyal commented 3 weeks ago

The concept of "path" is not well defined. If you want to use various heuristics to detect paths and perform arbitrary actions on them, see the hints kitten, that however is keyboard centric, not mouse based. In practice though you will find it far more efficient than using the mouse once you start using it.

brandondrew commented 3 weeks ago

How would I accomplish what I described with the hints kitten?

kovidgoyal commented 3 weeks ago

Read its docs to find out. If there is something specific, as opposed to a canned solution, you dont understand, feel free to ask.

brandondrew commented 3 weeks ago

Would you consider adding the functionality I've described?

brandondrew commented 3 weeks ago

I just discovered that this already exist for URLs. It would be extremely convenient if it could be added for file paths.

The concept of "path" is not well defined.

I don't know if you mean that I personally did not define well what I mean by "path", or if it is not currently defined within Kitty, or if you mean that the idea in general use in common discussion is not well defined.

kovidgoyal commented 3 weeks ago

paths are not well defined, in general. You need to apply some kind of heuristics to detect paths in a wall of text, which is what a terminal buffer is. As such, they are not well suited to auto-detection. The hints kitten allows you to define and control those heuristics very well, use it. I have no interest in adding mousing over paths.

brandondrew commented 3 weeks ago

I have no interest in adding mousing over paths.

So the real reason you closed this was because you're not willing to consider this feature request, right?