LinuxCommandLibrary

gist

Create Gists from the command line

TLDR

Log in to gist on this computer

$ gist --login
copy

Create a gist from any number of text files
$ gist [file.txt] [file2.txt]
copy

Create a private gist with a description
$ gist [[-p|--private]] [[-d|--description]] "[A meaningful description]" [file.txt]
copy

Read contents from stdin and create a gist from it
$ [echo "hello world"] | gist
copy

List your public and private gists
$ gist [[-l|--list]]
copy

List all public gists for any user
$ gist [[-l|--list]] [username]
copy

Update a gist using the ID from URL
$ gist [[-u|--update]] [GIST_ID] [file.txt]
copy

SYNOPSIS

gist [OPTION]... [FILE]...

PARAMETERS

-c, --copy
    Copy resulting gist URL to clipboard

-d, --delete ID
    Delete a gist by ID

-l, --list
    List your gists

-p, --paste
    Paste from clipboard or stdin

-r, --read ID
    Read and display a gist by ID

-u, --update ID
    Update existing gist with new content

-D, --description DESC
    Set gist description

-P, --public
    Make gist public (default: private)

-t, --type TYPE
    Set content-type for files

-a, --anon
    Upload anonymously (no login)

-o, --open
    Open gist URL in browser after upload

-f, --filename NAME
    Specify filename for stdin

-m, --message MESSAGE
    Set commit message

--version
    Display version info

-h, --help
    Show help message

DESCRIPTION

The gist command is a lightweight utility for creating, managing, and interacting with GitHub Gists directly from the terminal. It allows users to quickly share code snippets, notes, or files publicly or privately on GitHub's Gist service without needing a web browser.

Primarily used by developers, gist reads input from files or stdin, uploads it to GitHub via their API, and returns a shareable URL. It supports anonymous uploads, private gists, custom descriptions, filenames, and content types. Additional features include listing personal gists, reading or deleting existing ones, updating gists, and copying URLs to the clipboard.

To use it, install via RubyGems (gem install gist) or package managers like Homebrew. Authentication requires a GitHub personal access token stored in ~/.gist or environment variables. It's ideal for scripting workflows, logging, or rapid prototyping where sharing code is needed.

While powerful for GitHub users, it's not a core Linux utility and depends on network access and Ruby runtime.

CAVEATS

Requires GitHub token in ~/.gist; Ruby dependency; network required; not installed by default on most distros.

INSTALLATION

RubyGems: gem install gist
Debian/Ubuntu: apt install ruby-gist
macOS: brew install gist

CONFIGURATION

Create ~/.gist with token: your_github_token; generate token at github.com/settings/tokens with gist scope.

HISTORY

Created in 2009 by Chris Wanstrath (defunkt) as a Ruby script for GitHub team; evolved into a gem with API v3 support around 2012; maintained on GitHub with contributions for modern features like token auth.

SEE ALSO

curl(1), git(1), xclip(1)

Copied to clipboard