Skip to content

Commit 564efe2

Browse files
authored
utils/git: Add linkify script.
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 Reviewers: MaskRay Reviewed By: MaskRay Pull Request: #103496
1 parent 9a9ca98 commit 564efe2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/utils/git/linkify

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
# This script linkifies (i.e. makes clickable in the terminal) text that appears
4+
# to be a pull request or issue reference (e.g. #12345 or PR12345) or a
5+
# 40-character commit hash (e.g. abc123). You can configure git to automatically
6+
# send the output of commands that pipe their output through a pager, such as
7+
# `git log` and `git show`, through this script by running this command from
8+
# within your LLVM checkout:
9+
#
10+
# git config core.pager 'llvm/utils/git/linkify | pager'
11+
#
12+
# The pager command is run from the root of the repository even if the git
13+
# command is run from a subdirectory, so the relative path should always work.
14+
#
15+
# It requires OSC 8 support in the terminal. For a list of compatible terminals,
16+
# see https://github.com/Alhadis/OSC8-Adoption
17+
18+
sed \
19+
-e 's,\(#\|\bPR\)\([0-9]\+\),\x1b]8;;https://github.com/llvm/llvm-project/issues/\2\x1b\\\0\x1b]8;;\x1b\\,gi' \
20+
-e 's,[0-9a-f]\{40\},\x1b]8;;https://github.com/llvm/llvm-project/commit/\0\x1b\\\0\x1b]8;;\x1b\\,g'

0 commit comments

Comments
 (0)