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

Add OSC hyperlinks #261

Merged
merged 3 commits into from
Jul 22, 2020
Merged

Add OSC hyperlinks #261

merged 3 commits into from
Jul 22, 2020

Conversation

dandavison
Copy link
Owner

@dandavison dandavison commented Jul 22, 2020

Closes #257.

--hyperlinks   Render commit hashes, file names, and line numbers as hyperlinks, according to the
               hyperlink spec for terminal emulators:
               https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda. By default,
               file names and line numbers link to the local file using a file URL, whereas commit
               hashes link to the commit in GitHub, if the remote repository is hosted by GitHub.
               See --hyperlinks-file-link-format for full control over the file URLs emitted.
               Hyperlinks are supported by several common terminal emulators. However, they are
               not yet supported by less, so they will not work in delta unless you install a
               patched fork of less (see https://github.com/dandavison/less). If you use tmux,
               then you will also need a patched fork of tmux (see
               https://github.com/dandavison/tmux)
--hyperlinks-file-link-format <hyperlinks-file-link-format>
    Format string for file hyperlinks. The placeholders "{path}" and "{line}" will be replaced by the absolute
    file path and the line number, respectively. The default value of this option creates hyperlinks using
    standard file URLs; your operating system should open these in the application registered for that file
    type. However, these do not make use of the line number. In order for the link to open the file at the
    correct line number, you could use a custom URL format such as "file-line://{path}:{line_number}" and
    register an application to handle the custom "file-line" URL scheme by opening the file in your editor/IDE
    at the indicated line number. See https://github.com/dandavison/open-in-editor for an example [default:
    file://{path}]

@dandavison dandavison merged commit cac42e3 into master Jul 22, 2020
@dandavison dandavison deleted the 257-hyperlinks branch July 22, 2020 22:09
@dandavison
Copy link
Owner Author

cc @Kr1ss-XD, @navarroaxel new feature in master in case it's of interest. Locally, I have this so that command-click on any line number in delta opens my text editor on the file at that line number, but as you can see from the help text it takes a bit of set-up (OSC hyperlink terminal emulator codes not yet supported in less or tmux for starters.)

@Kr1ss-XD
Copy link
Contributor

That sounds ace !
I'll give it a shot this weekend, won't be able to get into it sooner, but thank you for the cc.

@dandavison
Copy link
Owner Author

This is what it looks like in iTerm2 (iTerm2 renders the hyperlinks with a dashed underline):

image

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

Successfully merging this pull request may close these issues.

🚀 Support displaying files and commits as OSC 8 hyperlinks
2 participants