Last active
December 13, 2015 23:29
-
-
Save readysetawesome/4992208 to your computer and use it in GitHub Desktop.
Turn the current directory's diff into a gist with a single .diff file (assumes you have osx with "pbcopy" and ruby)
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
function d2g() { | |
if [ -z "`git diff`" ] ; then | |
echo 'There is no diff to publish, brah.' | |
return | |
fi | |
if [ $# -eq 0 ] ; then | |
echo 'Please provide a name for the file.' | |
return | |
fi | |
curl -H "Authorization: token XXXXtokenWithGistScopeXXXX" -d "{\"description\":\"diff for branch: `git branch | grep \* | sed s/\*\ //g`, created: `date`\",\"public\":false,\"files\":{\"$1.diff\":{\"content\":\"`ruby -e 'require "rubygems";require "json";puts JSON.dump(\`git diff\`)[1..-2]'`\"}}}" https://api.github.com/gists | grep '^ "html_url": "https://gist.github.com' | sed s/\ \ \"html_url\"\:\ \"//g | sed s/\",// | pbcopy | |
} | |
# build a github token: curl -u 'username' -d '{"scopes":["gist"],"note":"Helper for quick gist from diff"}' https://api.github.com/authorization |
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
# create a gist with file named monday_project.diff, | |
# and place the newly created gist URL in my clipboard | |
d2g monday_project |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my sed statements are slightly fragile - changes to the JSON produced by github's API could break the final bit of this that extracts the new gist URL to the clipboard.