Skip to content

Instantly share code, notes, and snippets.

@wmoss
Created September 6, 2013 18:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wmoss/6468267 to your computer and use it in GitHub Desktop.
Save wmoss/6468267 to your computer and use it in GitHub Desktop.
Pipe to gist
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/",//'
}
@wmoss
Copy link
Author

wmoss commented Sep 6, 2013

Takes an optional parameter to specify the file type. For example git diff | gist diff or cat test.py | gist py

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