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