Last active
August 29, 2015 14:01
-
-
Save dschneller/0195b025f0703657030f to your computer and use it in GitHub Desktop.
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
#!/bin/bash -x | |
REPO="${1}" | |
SHA1="${2}" | |
OPEN="${3}" | |
repofragment=$(cd "$REPO"; git remote -v | grep origin | grep push | sed -e 's/.*github\.com.\(.*\)\.git.*/\1/') | |
url="https://github.com/${repofragment}/commit/${SHA1}" | |
echo "${url}" | pbcopy | |
[ -z "${OPEN}" ] || open "$url" |
Thanks for this! Works for me on SourceTree v2.0.5.2.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shell script designed to be used as an External Action in SourceTree to copy the selected commit's GitHub URL into the clipboard and optionally also open the selected commit on the GitHub website.
To use it, go to SourceTree Preferences, select the Custom Actions tab and add a new action.
Menu Caption: Open in GitHub
Script to Run: Path to where you put this script
Parameters: $REPO $SHA [yes]
Optionally define keyboard shortcut.
Now in any place where you can select a commit in SourceTree, hit your shortcut to invoke the script.
Any third parameter will cause commit to be opened on the GitHub website.
I wanted to have this to quickly comment on commits.
If you just need the URL in the clipboard without opening it, leave the third parameter out.
I have both variants on different keyboard shortcuts (Shift-G and Ctrl-Shift-G) in my SourceTree.