Last active
December 5, 2020 21:04
-
-
Save alxckn/00ad720b5476c426273f376f16f4b9a2 to your computer and use it in GitHub Desktop.
Open a given file in a Github pull request from Sublime Merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by https://forum.sublimetext.com/t/github-gitlab-bitbucket-integration-commands-menu-items/53893
Requires github cli