Show

The show command is for showing the contents of the snippet in your command line.

snippet show --name for_i

This will search the snippets for one named for_i. When multiple snippets are found, you’ll be presented with a list to choose from:

Multiple snippets found, which one would you like to view? (Press ↑/↓ arrow to move and Enter to select)
‣ for_i
  break_for_i
  for_i

Once a snippet is chosen it will be printed to the command line like this:

for 1 := 1; i < 10; i++ {
        // do something
}

From there you can observe or select and copy the snippet and use.

If you do not provide a name option, then an interactive list of snippet names will be shown. For all intents and purposes the name is optional.

Copy directly to clipboard

The show command supports a --copy flag that will automatically copy the snippet to your clipboard. To use, add the copy flag to your command like this:

./bin/snippet show --name for_i --copy

# OR:

./bin/snippet show --name for_i --copy=true

The snippet will render into the terminal as normal, but you should see a copy success message like this in the output as well:

COPIED: /path/to/snippets/golang/for_i.go

To use, simply ctrl/⌘ + v as you usually would.