Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pipe something from the command line to a new Github gist?

Tags:

I don't know if this exists yet, but I'd love to be able to do:

$ cat mygist.js | gh new gist 

And have it return the URL (and possibly copy it to the clipboard / open it in the browser).

like image 773
agentofuser Avatar asked Nov 25 '12 15:11

agentofuser


People also ask

How do I add files to gist?

Go to your Gist and click the Edit button at the top right. The Gist editor will show your files in edit mode, then look at the bottom left and there you will find an 'Add file' button. Click it and the cursor will be moved to the 'File name box..', type a name and click the 'Update gist' button at the bottom right.

How do I edit my GitHub gist?

How Do I Edit or Delete a Gist? In the top right corner of your gist page, there will be a menu that allows for multiple functions to be performed on your gist. We can edit, delete, unsubscribe, star, embed, copy, share, and download a raw copy or zipped copy of a gist.


1 Answers

Seems like GitHub has a simple REST API, including methods for creating Gists. Just for fun:

$ curl -X POST \     --data-binary '{"files": {"file1.txt": {"content": "Hello, SO"}}}' \     https://api.github.com/gists 

This successfully created this Gist. I guess it's enough to get you started.

like image 86
Tomasz Nurkiewicz Avatar answered Sep 19 '22 12:09

Tomasz Nurkiewicz