How to create a gist on command line

梦想的初衷 提交于 2019-12-03 03:18:48

I've just tried

curl -X POST -d '{"public":true,"files":{"test.txt":{"content":"String file contents"}}}' -u mgarciaisaia:mypassword https://api.github.com/gists

and it worked: https://gist.github.com/mgarciaisaia/fa51238073eb2cf508aa

I don't see any problem in your command.

This question is old, so I am not sure it is still relevant.

On Ubuntu (at least on 18.04), you can try the gist package, which will install the gist-paste command that you can use (given you have a git account already) as below:

1) Get a gist OAuth2 token (it will create a ~/.gist file with the token). You have to do it once only:

$ gist-paste --login

Then, you can send your files, for instance:

$ gist-paste your-file.txt
$ cat .emacs.d/init.el | gist-paste -t el

There are many options: You can send file type/description (as above second example), delete gists, open gist in browser, etc... See gist-paste(1) or try gist-paste --help.

If you already have a gist token, you don't need to run gist-paste --login, just copy your ~/.gitconfig's oauth-token to ~/.gist. For example, if you have in ~/.gitconfig:

[github]
    oauth-token = foobar123

Just create a ~/.gist file with one line containing "foobar123".

[Edit] If your distribution does not provide the package, the project page is: https://github.com/defunkt/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...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!