mre / prettyprint

Beautifully formatted output for your terminal 🌈
Apache License 2.0
200 stars 10 forks source link

Output hyperlink for filename ? #4

Closed stuaxo closed 5 years ago

stuaxo commented 5 years ago

Any chance of making the title a hyperlink to the file, this would make it easy to right click and open it in my editor.

mre commented 5 years ago

Not sure if that is possible, given that we're talking about text output here. One thing I could think of are using absolute paths in the title, such as /path/to/file.rs. This way, if I command-click on the title using zsh, it will open the file for me. You can give it a shot and see if it works. Similarly, you can use public web URLs for the files, for example if the project is hosted on Github; that also works for me.

If there is a trick that I don't know of to create links inside terminal output, feel free to add it here. 😃

stuaxo commented 5 years ago

There is a new hyperlink standard for ANSI, I should have linked to it but it was very late at night - https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

I don't think there is a good way to detect it at the moment, so some people choose to only enable it via a config option in their programs, though I'm pretty sure it should be hidden on most sane terminal emulators.

stuaxo commented 5 years ago

BTW, you can play with it in gnome-terminal, tilix (or other vte based terminals) by simply using

ls --hyperlink

mre commented 5 years ago

What sorcery is this? 🧙 That's quite fancy. If there is a crate for creating those links, we could add an optional argument to the builder, e.g. hyperlinks or render-links or so. If there is no crate, that would be a good opportunity to create one.

stuaxo commented 5 years ago

It's such a small functionality, should it be a crate ?

I'm definitely up for doing this as I've been procrastinating learning rust for 3 years now.

stuaxo commented 5 years ago

It feels like it should be part of a general ansi output crate, but I guess if the other crate only deals with colour then it's not the right place.

mre commented 5 years ago

However you prefer. I don't mind smaller crates as they can be combined into bigger libraries quite easily thanks to cargo workspaces. Maybe you'd like to start small and see where it leads you. Better to have something maintainable and useful today than the perfect solution in a year. :wink:

stuaxo commented 5 years ago

OK, I'll close this ticket for now, and if I get a crate done then come and re-open it.

mre commented 5 years ago

Thanks :+1: