gist: manage GitHub gists

git_logo_compGitHub gists are a good way to write quick notes or code snippets or configurations and share those with others. There are a few cmdline clients mentioned officially but they are either unmaintained or lacking in features or need ruby. Today we came across a new client being actively developed in Python – gist.

Features

  • Print a list of your gists
  • Print detailed information about a gist
  • Print a list of the files in a gist
  • Delete a gist from github
  • Download a gist and creates a tarball
  • Print the content of the gist to stdout
  • Create a new gist (as private or public)
  • Clone a gist

The author is actively working on gist edit and it currently works with the user’s default editor. In addition the gist create command (without any argument) opens up the default editor to create a new gist on the fly.

Installation

To install the gist client on Ubuntu, run the following:

$ sudo apt-get install python-setuptools
$ git clone https://github.com/jdowner/gist.git
$ cd gist
$ sudo make install

It supports TAB-completion. To enable it, add the following line in your ~/.bashrc:

source /usr/share/gist/gist.bash

Usage

You need to generate a personal access token from your GitHub settings -> Applications page and add it to ~/.gist in the form:

[gist]
token: <enter token here>

Options

gist list    : prints a list of your gists
gist info    : prints detailed information about a gist
gist files   : prints a list of the files in a gist
gist delete  : deletes a gist from github
gist archive : downloads a gist and creates a tarball
gist content : prints the content of the gist to stdout
gist create  : creates a new gist
gist clone   : clones a gist

There are multiple ways to create a gist from different sources.

  • Create from a set of files
    $ git create "gist_new" foo.txt bar.txt
  • Create from clipboard data
    $ xclip -o | gist create "gist_clip"
  • From some on the fly notes
    $ echo $(cat) | gist create "gist_quick"

Webpage: gist

Leave a Reply

Your email address will not be published. Required fields are marked *