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).
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).
Try this gem: https://github.com/defunkt/gist
Worked for me ^_^
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.
Here's a simple bash script that takes a filename and makes it a gist.
function msg() {
echo -n '{"description":"","public":"false","files":{"file1.txt":{"content":"'
awk '{gsub(/"/,"\\\""); printf "%s\\n",$0}' "$1"
echo '"}}'
}
[ "$#" -ne 1 ] && echo "Syntax: gist.sh filename" && exit 1
[ ! -r "$1" ] && echo "Error: unable to read $1" && exit 2
msg "$1" | curl -v -d '@-' https://api.github.com/gists
FYI: gist replies with the post body, so if the file is big, perhaps grep just the relevant parts of the reply.
As Ronie said above, there is a gist gem which provides a gist command that you can use from your terminal to upload content to https://gist.github.com/
To upload the contents of a.rb just:
gist a.rb
More info http://defunkt.io/gist/
Have the same desire I found https://www.npmjs.com/package/gistup and fork the repository to https://github.com/CrandellWS/mkg because the developer did not want to support Windows which was the operating system being used at the time. So I reworked the npm package to work on windows as well as linux and apple...
Full source is available on GitHub: https://github.com/CrandellWS/mkg
Installation is simple with npm
npm install -g mkg
Use is discribed on the npmjs package page: https://www.npmjs.com/package/gistup
Once installed simply cd
to which every directory you want to make a gist from...(remeber there are no subfolders with Gists)
and run the command:
mkg
and it will open your new gist in a broswer...additionally you will be able to control it like a normal git from there... just no subfolders...
https://stackoverflow.com/a/41233970/1815624
A super simple command I like to use for making gists out of diff
s is:
git diff origin master -U15 | gist -t diff
Where 15
is the line spacing you can have before and after the change (So it's easier to see differences in larger files.)
-t
is the type
flag.