aboutsummaryrefslogtreecommitdiffhomepage

gist - Manage your gist like a pro

All your notes, scripts, config files and snippets deserve version control and tagging!
gist is a simple bash script for gist management, lite and dependency-free!
Use it to boost your coding workflow.

Getting Started

# Install script
curl -fsSL https://raw.githubusercontent.com/typebrook/gist/master/install.sh | bash
# Fetch your gists and clone them into ~/gist as git repos
gist fetch
# List your gists
gist
# Create a new gist
gist new
# Create private gist with files 'foo' and 'bar'
gist new -p foo bar
# Check information of your third gist
gist detail 3
# Get the path and cd to cloned repo with subshell
gist 3
# List your gists with tags instead of URL
gist tag
# Add tags to your third gist
gist tag 3
# Update the description of your third gist
gist edit 3
# Push changes in your third gist to the remote repo
gist push 3
# Delete gists with indices 3, 4 and 5
gist delete 3 4 5
# Or use Brace Expansion
gist delete {3..5}
# Export your third gist as a new Github repo with web page
gist github 3
# For more detail, read the helper message
gist help

Basic Commands

Update and clone gists from Github

Run gist fetch to fetch your all gists with Github API and keep short information for each gist in a index file inside a given folder. (default to ~/gist/index) - Automatically Clone/Pull each gist with git into a given folder. (default to ~/gist/) - Run gist fetch star to fetch you starred gist - If token is not being set, then you cannot fetch your private gist

List your gists

Run gist to read index file (default to ~/gist/index) and list your gists with the following format:

<index> <gist-URL> <files-number> <comments-number> <description>
like the following:

  • Use gist star to show your starred gists
  • Use gist all to show your and starred gists
  • Index with prefix s is a starred gist, index with prefix p is a private gist
  • There are colorful hints for each gist in the following cases:
    • working Some changes are made locally but not yet do git commit, or you are not in master branch
    • ahead Your local HEAD is yet to be applied to upstream
    • outdated Your local HEAD is differs from the last fetched gists, do gist fetch to refresh index file and pull if needed

Create a new gist

Run gist new to create a new gist - You can create a new gist with 3 different ways: 1. type the content by hand, run gist new 2. use existing files, run gist new <file1> <file2>... 3. from STDIN, like <command> | gist new - You can specify filename with --file, and description with --desc, like gist new --file new --desc 'a new gist' - If you don’t specify filename or description, a prompt will shows up!

Modify a gist

Run gist <INDEX> to enter sub-shell with working directory of the given gist index (by default action). You can do some trick with custom action.(See action and Tips)

Since now a gist is a local cloned repo, it is your business to do git commit and git push. Use gist push <INDEX> is not recommended.

Clean unnecessary local repos

Say you delete gists with command gist delete <index-of-gist>..., the local git repositories are still at ~/gist/. Run gist clean to move them into /tmp

Configuration

gist stores your configuraion inside ~/.config/gist.conf, with <key>=<value> format for each line. And just do source ~/.config/gist.conf at runtime.