Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a gist on command line

Tags:

I am trying to create a gist from bash, and I have tried many versions scripts I could get, but none are working.

This seems like a correct one, but it does not work also.

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

I have a test.txt file with content I would like to create the gist, but it won't work. It says, invalid email, if I try to add -u USER or -u USER:PASS it still won't work saying "message": "Problems parsing JSON", ..

I don't know what is wrong. the documentation does not provide much except for this line:

POST /gists as you can see, I am passing the test.txt file.

like image 505
trbvm Avatar asked Dec 02 '15 16:12

trbvm


People also ask

What is GIST Linux?

Gist is an easy method to share snippets or excerpts of data with others. A gist can be a string of code, a bash script or some other small piece of data. These bits of information are hosted by GitHub as a repository.


1 Answers

Recently GitHub CLI released. So you can now use it instead.

Just install it to your system (https://github.com/cli/cli#installation)

The authenticate (it's pretty simple)

gh auth login 

After you logged in you can simply create a new gist by:

gh gist create -d "my test gist" -f some_local_file.txt  test_gist 

For more details you can use help:

gh <command> <subcommand> --help 
like image 167
Nickolay Kondratenko Avatar answered Sep 19 '22 13:09

Nickolay Kondratenko