Giter Club home page Giter Club logo

gg's Introduction

gg

A CLI for your Gists. It syncs your gists locally, making them searchable and quickly accessible.

Installation

Download the latest release for your system.

# Move the binary to a location on your $PATH and rename to gg
mv gg_linux /usr/local/bin/gg
chmod +x /usr/local/bin/gg_linux
# gg should now work
gg

Features

  • Syntax highlighting in terminal
  • Create, edit, and delete gists from the command line
  • Edit gists in a text editor (e.g. sublime)
  • Organize gists using tags (#hashtag syntax)
  • Full text search
  • Filter and sort by tag, language, owner, public/private, starred, search term
  • gg includes starred gists by other users
  • Summarize gists by tag, language, or owner

Usage

Getting Started

  1. Create a new authentication token. Under permissions select 'gist'
  2. Run gg sync --token <authentication_token>.

Query Gists

gg ls can be used to search and filter your gist library. Results are output in a table. For convenience, the ls command is run implicitly when gg is invoked as long as the term being passed is not also a command.

For example:

gg # Lists recent gists
gg ls # equivelent to above

gg genomics # Searches gists for the term 'genomics'
gg ls genomics # equivelent to above

gg -l 100 # lists last 100 gists.
gg ls -l 100 # lists the last 100 gists

gg help # shows help
gg sync # syncs gists

The gg command list is:

  • # - any integer number.
  • help, h, --help, -h
  • sync
  • set-editor
  • logout
  • new
  • edit
  • web, w
  • open, o
  • rm
  • ls, list
  • search
  • starred
  • tag, tags
  • language, languages
  • owner
  • __run_alfred, debug

You can still search on these terms by using ls explicitly:

gg sync # runs the sync command
gg ls sync # searches for the term 'sync'

Gist List

Retrieve Gists

gg open 5 # Outputs a single gist
gg o 5 # 'o' is a shortcut for open.

# To be even quicker, gg will open a gist when the first argument is an integer.
gg 5 # equivelent to `gg o 5` or `gg open 5`

# Output multiple gists
gg 5 8 22

# You can pipe the contents to be evaluated; They will not be syntax-highlighted
gg 5 | sh

Gist Retrieval

Summarize gists

Gists can be summarized by tag, owner, and language.

gg tags # Summarize by tag
gg tags fastq # Query gists tagged with 'fastq'
gg tags fastq elegans # Query gists tagged with 'fastq' and containing the word 'elegans'
gg owner # List owners and count
gg language # Table languages and count

summary output

Creating new gists

Files

The following will create a new gist that includes both analysis.R and setup.sh

gg new --description "analysis scripts" analysis.R setup.sh 

stdin

You can also pipe input into gg to create a new gist, and set gists to --private

cat analysis_results.tsv | gg new --description "experiment results" --private

Clipboard

You can create a new gist from your clipboard

gg new --clipboard --description "A new gist" --filename "analysis.sh"

Edit Gists

Use gg edit to edit gists.

gg edit 12 # Open gist in text file for editing.

Editing a gist opens a text document with the following header:

# GIST FORM: Edit Metadata below
# ==============================
# description: tmux shortcuts & cheatsheet
# starred: T
# public: T
# ==============================

You can modify the description, starred (T=true; F=false), and public (T=true; F=false) in this header.

Following the header you will see a special separator line that looks like this:

myscript.sh----------------------------------------------------------------------------::>>>

Because gists can have multiple files, they are represented in a single file by breaking them up using a specialized line. The line must begin with the filename, followed by dashes ---, and finally end with ::>>>. A gist with two files looks like this:

# GIST FORM: Edit Metadata below
# ==============================
# description: analysis.R
# starred: T
# public: T
# ==============================
README.md-----------------------------------------------------------------------------::>>>
I used R to analyze my data!

Check out analysis.R to see how I did it.
analysis.R----------------------------------------------------------------------------::>>>
# My R script
print(1 + 1)

Supported editors:

  • Sublime Text (subl)
  • Nano

Remove Gists

Use gg rm to delete gists.

gg rm 12
gg rm 12 134 47 # Remove multiple gists

Contributing

Feel free to open a PR or suggest changes! Relatively new to Go, so technique suggestions are especially welcome.

gg's People

Contributors

danielecook avatar todo-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

0xack13

gg's Issues

broken

owner
language

Broken

open

open gist in browser or by search

gg open <id>
gg open "search term" # must result in single unique

If non-unique, prompt user with (1/2/etc.) option

owner issue

  OWNER  | COUNT
---------+--------
       2 |     1
  ggtest |     1

search gists

Use terms != ls, login, etc. as search terms
Allow explicit setting search term with -s flag

ls

Add ability to LS again without specifying directly.

non-flag args in qstring

  • Fix issue where --status private included in qstring and prevents results from showing up.
  • Bundle flag arguments for ls

edit

  • Break up function to allow for edit v. new
  • Allow new gists to be created using template
  • gist template parser
  • Validate gist template input and re-open on error
  • Edit existing gists
  • Allow multiple files using @filename----> break syntax? Should be unique enough.
  • Show URL upon edit
  • Implement $EDITOR for selecting editor or user config EDITOR setting (config with prompt?)
  • Show warning when trying to edit another users gist

new gist

How will new functionality work?

  • new on it's own opens webpage
gg new # opens webpage
gg new --title <> --filename <> --content (or stdin) # creates remotely
gg new --editor # open editor and prefill content; store on save.

minor issues

  • Filtering by star
  • Filtering by fork
  • Sorting by custom field
  • Language summary and search
  • tag

ls - list all gists

  • Sort - reverse, by description; language; tags
  • Filter by language
  • Filter by tag
  • verbose?
  • syntax highlighting

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.