Skip to content

Instantly share code, notes, and snippets.

@alxckn
Last active December 5, 2020 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alxckn/00ad720b5476c426273f376f16f4b9a2 to your computer and use it in GitHub Desktop.
Save alxckn/00ad720b5476c426273f376f16f4b9a2 to your computer and use it in GitHub Desktop.
Open a given file in a Github pull request from Sublime Merge
[
{
"caption": "Open file in github PR",
"command": "git",
"args": {"argv": ["gh-pr-open-file", "$path"]}
}
]
[
{
"caption": "Open file in github PR",
"command": "git",
"args": {"argv": ["gh-pr-open-file", "$path"]}
}
]
git config --global alias.gh-pr-open-file '!f() {
local FILE_PATH="$1"
PR_URL=$(gh pr view | grep -oP "(?<=url\:\t).*")
if [ -z "$PR_URL" ]; then
echo "Cannot open: not able to find a github PR with current branch" >&2
return 1
fi
FILE_PATH_CHECKSUM=$(echo -n "$FILE_PATH" | sha256sum | head -c 64)
xdg-open "$PR_URL/files#diff-$FILE_PATH_CHECKSUM"
}; f'
@alxckn
Copy link
Author

alxckn commented Dec 5, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment