Hyperlinks
Opened this issue · 7 comments
It would be great if the better exceptions could output file:/// hyperlinks using the new ansi standard.
I'm not quite sure which bit of the output should be the link.
Unfortunately AFAICT line numbers aren't supported, but just being able to click from somewhere in the exception and open the file would be a big plus.
https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
The problem is that detecting those terminals is very hard. This would break a lot of people, unfortunately.
I'd be happy setting an environment variable or config option to enable it.
It's semi-useful being able to open files by right-clicking after ls --hyperlink
opening files from tracebooks would be very useful.
Perhaps. If someone wants to submit a PR I'd be happy to consider it. But it has to be enable-able via environment variable for now.
Quick note to myself on where to find the filename output:
https://github.com/Qix-/better-exceptions/blob/master/better_exceptions/formatter.py#L253
Another note, about how this becomes a bit annoying under docker - paths are different (though the hostname bit of the file url being different would alert the terminal emulator) - this is a bit past the MVP of getting this working at all though.
There's no feasible way to do that in docker, really. That would just add to the complexity and not something we should support.
That bit was definitely a note too myself, that's something the terminal emulator could do eventually, convert remote URLs to local ones, e.g.
file://some-hostname-docker-came-up-with/somepath/myfile.py
to
file://localhost/some/docker-mountpoint/somepath/myfile.py
But I make have a fork of this, that can replace the beginning bit of the path somehow, as my current dev is all in docker containers :/
Here's an initial go at a PR https://github.com/Qix-/better-exceptions/pull/97
No tests yet.