Created
September 6, 2013 18:51
-
-
Save wmoss/6468267 to your computer and use it in GitHub Desktop.
Pipe to gist
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 gist { | |
# Create token using: https://help.github.com/articles/creating-an-access-token-for-command-line-use | |
json=$(python -c "import json; import sys; print json.dumps(sys.stdin.read())") | |
resp=$(curl --silent --user "<YOUR USERNAME HERE>:" -H "Authorization: token <YOUR TOKEN HERE>" --request POST --data '{"public": false, "files": { "file.'$1'": { "content": '$json' } } }' https://api.github.com/gists) | |
echo $resp | fgrep "html_url" | fgrep "gist" | sed -e 's/.*: "//' -e 's/",//' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Takes an optional parameter to specify the file type. For example
git diff | gist diff
orcat test.py | gist py