What’s snippet/gist?

gist is a piece of code or maybe some important text shared on Github or Gitlab. It’s actually a git repository so you can clone it, work on it locally and push changes.

Share gists from Terminal

There are multiple programs available in many distributions for this purpose. You just have to find it. On Arch Linux, you can install gist.

Here is how it works in terminal.

share text using gist

You can update an existing gist if you know its hash ID. It has a man page yeah ;-)

Share gists from EDITOR

If you’re using vim, add this line to your ~/.vimrc.

$ command! -range=% GT <line1>,<line2>w !gist -c -p -f %

Now in command mode, you can type GT and hit enter to create a snippet from your editor’s window.

Get gists output in Terminal

So now you know how to share snippets from terminal. But what if someone has given you some URL and you want to see it in terminal?

I have got this snippet shared, for example

It’s hosted on github at this URL.


Using cURL or wget you will get this github page html in your terminal.

So here is a magic trick for you ;-)

Replace github.com to githubusercontent and append /raw at the end.

The above snippet’s URL now becomes:


Now you can use cURL or wget to see/save the snippent right from your terminal.

get text from gist

That’s it. You can save it to some file as well.

Thanks for reading.