Skip to content

utils/git: Add linkify script. #103496

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

Merged
merged 1 commit into from
Aug 15, 2024
Merged

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Aug 14, 2024

This script linkifies (i.e. makes clickable in the terminal) text that appears
to be a pull request or issue reference (e.g. #12345 or PR12345) or a
40-character commit hash (e.g. abc123). You can configure git to automatically
send the output of commands that pipe their output through a pager, such as
git log and git show, through this script by running this command from
within your LLVM checkout:

git config core.pager 'llvm/utils/git/linkify | pager'

The pager command is run from the root of the repository even if the git
command is run from a subdirectory, so the relative path should always work.

It requires OSC 8 support in the terminal. For a list of compatible terminals,
see https://github.com/Alhadis/OSC8-Adoption

Created using spr 1.3.6-beta.1
@pcc pcc requested a review from MaskRay August 14, 2024 01:56
@MaskRay
Copy link
Member

MaskRay commented Aug 14, 2024

Thanks! This is useful.

@pcc pcc merged commit 564efe2 into main Aug 15, 2024
9 checks passed
@pcc pcc deleted the users/pcc/spr/utilsgit-add-linkify-script branch August 15, 2024 00:25
@MacDue
Copy link
Member

MacDue commented Aug 15, 2024

For this to work for me I have to do:

# Note: pager is an alias of less (here)
git config core.pager 'llvm/utils/git/linkify | pager -r'

-r forces less to interpret the ANSI codes.

Otherwise, it appears as:

 (8;;https://github.com/llvm/llvm-project/issues/101748#1017488;;)

Also, there may be some security implications from that... but I assume you can treat the LLVM repo as safe.

@pcc
Copy link
Contributor Author

pcc commented Aug 15, 2024

Interesting. For me I have LESS=FRX in the pager environment. This is added by Git when it launches the pager; the R causes it to interpret ANSI codes. Maybe you are overriding LESS to something else? Do you have colors enabled (git config color.ui) and do they display properly?

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.

3 participants