All Projects β†’ out-of-cheese-error β†’ The Way

out-of-cheese-error / The Way

Licence: mit
A command line code snippets manager

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to The Way

Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+7517.42%)
Mutual labels:  cli, command-line, snippets
Coinmon
πŸ’° The cryptocurrency price tool on CLI. πŸ–₯
Stars: ✭ 1,581 (+1097.73%)
Mutual labels:  cli, command-line
Cum
comic updater, mangafied
Stars: ✭ 117 (-11.36%)
Mutual labels:  cli, command-line
Chest
Bash glue to encrypt and hide files
Stars: ✭ 123 (-6.82%)
Mutual labels:  cli, command-line
Gest
πŸ‘¨β€πŸ’» A sensible GraphQL testing tool - test your GraphQL schema locally and in the cloud
Stars: ✭ 109 (-17.42%)
Mutual labels:  cli, command-line
Httpcat
httpcat is a simple utility for constructing raw HTTP requests on the command line.
Stars: ✭ 109 (-17.42%)
Mutual labels:  cli, command-line
Spectre.cli
An extremely opinionated command-line parser.
Stars: ✭ 121 (-8.33%)
Mutual labels:  cli, command-line
Glsnip
copy and paste across machines
Stars: ✭ 107 (-18.94%)
Mutual labels:  cli, snippets
Clrcli
CLRCLI is an event-driven library for building line-art user interfaces in C#/.Net command-line applications.
Stars: ✭ 124 (-6.06%)
Mutual labels:  cli, command-line
Nnn
nΒ³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+9853.03%)
Mutual labels:  cli, command-line
Dynein
DynamoDB CLI written in Rust.
Stars: ✭ 126 (-4.55%)
Mutual labels:  cli, command-line
Yq
Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents
Stars: ✭ 1,688 (+1178.79%)
Mutual labels:  cli, command-line
Word Wrap
Wrap words to a specified length.
Stars: ✭ 107 (-18.94%)
Mutual labels:  cli, command-line
Nodejs Cli Apps Best Practices
The largest Node.js CLI Apps best practices list ✨
Stars: ✭ 2,144 (+1524.24%)
Mutual labels:  cli, command-line
Simple Console
Add an elegant command-line interface to any page
Stars: ✭ 107 (-18.94%)
Mutual labels:  cli, command-line
Bull Repl
Bull / BullMQ queue command line REPL
Stars: ✭ 121 (-8.33%)
Mutual labels:  cli, command-line
Grmon
Command line monitoring for goroutines
Stars: ✭ 1,703 (+1190.15%)
Mutual labels:  cli, command-line
Awesome Cli
A curated list of awesome resources for building immersive CLI experiences.
Stars: ✭ 104 (-21.21%)
Mutual labels:  cli, command-line
Clikt
Multiplatform command line interface parsing for Kotlin
Stars: ✭ 1,658 (+1156.06%)
Mutual labels:  cli, command-line
Flow Cli
The Flow CLI is a command-line interface that provides useful utilities for building Flow applications
Stars: ✭ 123 (-6.82%)
Mutual labels:  cli, command-line

Crates.io Build Status GitHub release dependency status GitHub license

The Way

A code snippets manager for your terminal.

Record and retrieve snippets you use every day, or once in a blue moon, without having to spin up a browser. Just call the-way new to add a snippet with a description, a language, and some tags attached.

the-way search fuzzy searches your snippets library (with optional filters on language and tags) and lets you

  • edit a snippet with Shift-Right
  • delete a snippet with Shift-Left
  • copy a particular snippet to your clipboard (with Enter), so you can paste it into whatever editor or IDE you're working with.

See it in action (with some self-referential examples):

demo

made with asciinema, svg-term-cli, and svgembed

Table of Contents

Install

Requirements

xclip on Linux and pbcopy on OSX

Binaries

See the releases

  • OSX - allow the-way via System Preferences (necessary in Catalina at least)
  • Linux - chmod +x the-way
  • Currently doesn't work on Windows (waiting on this issue)

With brew

brew tap out-of-cheese-error/the-way && brew install the-way

With cargo

cargo install the-way

With yay

yay -S the-way-git

On Android

Needs Termux, Termux:API and pkg install termux-api

Clone the repository, run cargo build --release, and use target/release/the-way

Upgrading

Some upgrades need a database migration (mentioned in the release notes):

  • Before upgrade
the-way export > snippets.json
the-way clear
  • After upgrade
the-way import snippets.json

Usage

Record, retrieve, search, and categorize code snippets

USAGE:
    the-way <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    new         Add a new code snippet
    cmd         Add a new shell snippet
    search      Fuzzy search to find a snippet and copy, edit or delete it
    sync        Sync snippets to a Gist
    list        Lists (optionally filtered) snippets
    import      Imports code snippets from JSON
    export      Saves (optionally filtered) snippets to JSON
    clear       Clears all data
    complete    Generate shell completions
    themes      Manage syntax highlighting themes
    config      Manage the-way data locations
    edit        Change snippet
    del         Delete snippet
    cp          Copy snippet to clipboard
    view        View snippet
    help        Prints this message or the help of the given subcommand(s)

Features

Main features

  • Add code and shell snippets
  • Interactive fuzzy search with edit, delete and copy to clipboard functionality
  • Filter by tag, date, language and/or regex pattern
  • Import / export via JSON
  • Import from Gist (with the-way import -g <gist_url>)
  • Sync to gist
  • Syntax highlighting

Shell commands

the-way cmd (inspired by pet) makes it easier to save single-line bash/shell snippets with variables that can be filled in whenever the snippet is needed.

Add the following function according to your shell of choice. Every time you spend ages hand-crafting the perfect command: run it, close all the stackoverflow tabs, and run cmdsave to save it to the-way. You can then use cmdsearch to search these shell snippets and have the selected one already pasted into the terminal, ready to run.

bash

function cmdsave() {
  PREV=$(echo `history | tail -n2 | head -n1` | sed 's/[0-9]* //')
  sh -c "the-way cmd `printf %q "$PREV"`"
}

function cmdsearch() {
  BUFFER=$(the-way search --stdout --languages="sh")
  bind '"\e[0n": "'"$BUFFER"'"'; printf '\e[5n'
}

zsh

function cmdsave() {
  PREV=$(fc -lrn | head -n 1)
  sh -c "the-way cmd `printf %q "$PREV"`"
}

function cmdsearch() {
  BUFFER=$(the-way search --stdout --languages="sh")
  print -z $BUFFER
}

fish

function cmdsave
  set line (echo $history[1])
  the-way cmd $line
end

(todo: add fish cmdsearch)

You'll usually want different parameters each time you need a shell command: save variables in a shell snippet as <param> or <param=default_value> and every time you select it you can interactively fill them in (or keep the defaults). Parameters can appear more than once, just use the same name and write in the default the first time it's used.

Here's another self-referential example that saves a shell command to add new language syntaxes:

cmd_demo

made with asciinema, svg-term-cli, and svgembed

(todo: change GIF to use cmdsearch instead of search)

Sync to Gist

the-way sync syncs snippets to a Gist, each named snippet_<index>.<extension>, with an index.md file linking each snippet's description. Local updates and deletions are uploaded to the Gist and Gist updates are downloaded.

gist

This functionality needs a GitHub access token with the "gist" scope. Either enter this token on running sync for the first time or set it to the environment variable $THE_WAY_GITHUB_TOKEN.

Shell completions

the-way complete zsh > .oh-my-zsh/completions/_the-way
exec zsh

Syntax highlighting

The Way maps languages to their extensions and uses this to

  1. Enable syntax highlighting in $EDITOR (if the editor supports it),
  2. Upload snippets to Gist with the correct extension,
  3. Add a small colored language indicator (GitHub-flavored)
  4. Syntax highlight code in the terminal

The last point can be customized via the-way themes.

Use the-way themes set to see available themes and enable a theme.

Default themes:

Darcula
InspiredGitHub
Solarized (dark)
Solarized (light)
base16-eighties.dark
base16-mocha.dark
base16-ocean.dark
base16-ocean.light
base16-tomorrow.dark
base16-twilight.dark

Use the-way themes add <theme.tmTheme> to add a new theme to your themes folder. Theme files need to be in Sublime's .tmTheme format. Searching GitHub for .tmTheme pulls up some examples.

Use the-way themes language <language.sublime-syntax> to add highlight support for a new language (many languages are supported by default). Syntax files need to be in Sublime's sublime-syntax format. Zola has a nice collection of such files.

Here's how it looks before and after adding Kotlin.sublime-syntax:

  • Before:

kotlin_plain

  • After:

kotlin_highlight

To get syntax highlighting for code blocks in markdown files, download and add the patched Markdown.sublime-syntax file in this repository, taken from bat (the default syntax file doesn't do this anymore)

Configuration

The default config TOML file is located in

  • Linux: /home/<username>/.config
  • Mac: /Users/<username>/Library/Preferences

This file contains locations of data directories, which are automatically created and set according to XDG and Standard Directories guidelines. Change this by creating a config file with the-way config default > config.toml and then setting the environment variable $THE_WAY_CONFIG to point to this file.

Why "The Way"?

The name is a reference to the Way of Mrs.Cosmopilite, kōans for every situation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].