Corgi is a command-line tool that helps with your repetitive command usages by organizing them into reusable snippet. See usage by simply running corgi
or corgi --help
Current version: v0.2.2
Create a new snippet to automate the commands you run repetitively
Execute an existing snippet knowing what command is being run and its output
Run brew install drakew/corgi/corgi
and you are good to roll!
To install the binary directly:
- Download the latest package tarball from releases based on your system (currently support linux and macOS).
- Unzip the package with
tar -xzvf <downloaded tar.gz file>
cd <directory extracted>
, andchmod a+x ./corgi
to make sure execution bit is turned.ln -s $(pwd)/corgi <your bin folder>/corgi
to create a softlink- Start rolling with
corgi
To build the executable from scratch:
- Install the most recent version of
go
language on your system git clone [email protected]:DrakeW/corgi.git
- Run
go build -o corgi
inside of the repo ln -s $(pwd)/corgi <your bin folder>/corgi
corgi
will enable interactive selection if you install a fuzzy finder, the currently supported two are fzf and peco.
To view usage of a specific action, run corgi <action> --help
corgi provides an interactive CLI interface to create snippet, and you can start by running
corgi new
If you would like to quickly combine the last couple commands you just executed into a snippet, you could also run
corgi new --last <number of commands to look back>
Furthermore, you could also add template fields (with or without default value) to command of a step and reuse the same field, for example:
tar -xzf <project>.tgz && scp <project> <user=ec2-user>@<ec2-instance-address>:~/
And you will be prompted to enter values for those fields when the snippet executes. The value set for the same field name will be applied to all steps in a snippet, so you don't have to enter multiple times.
Also if you have field with multiple default values, the latest appearance will take precedence over the previous values.
To view all snippets saved on your system, run
corgi list
To execute a snippet, simply run
corgi exec [<title of the snippet>] [--use-default] [--step <step range>]
Your commands will run smoothly just as they were being run on a terminal directly, and any prompt that asks for input (for example, password prompt when you ssh
into a remote server) will work seamlessly as well.
Also note that if you run cd
command in one of the steps, the current working directory will not change for subsequent steps. But you can always put cd <target dir> && <do something else>
to get commands executed inside of your target directory.
if --use-default
is set, then the snippet will execute without asking explicitly for user to set a value for template fields defined, but if there are missing default values, the snippet will fail fast and tell you what fields are missed.
You can use the --step
(or -s
) flag to specify the steps (starting from index 1) you want to execute, for example
--step 3 # will only execute step 3
--step 3-5 # will execute step 3 to 5
--step 3- # will execute step 3 to the last step
This can be particularly useful when your workflow fail midway, but you don't want to start the whole workflow from step 1 again.
This feature will guide you through the darkness if you don't have the title of your snippet memorized. Simply type
corgi exec [with or without options]
and you will be presented an interactive interface to fuzzy-find your snippet (To enable this feature, see installation instruction)
To edit a snippet, run
corgi edit [<title of the snippet>]
You'll be able to edit the snippet json file directly with your preferred editor (configurable via corgi config
command, details see below)
Furthermore, edit
also provides fuzzy finding capabilities when you omit the snippet title.
To see the details of a snippet, you can run (without title will yield interactive title selection)
corgi describe [<title of the snippet>]
And it will print out each step of the snippet so that you don't have to memorize them.
If someone shares his/her snippet json file(s) with you, you can import it by running
corgi import <snippet json file 1> [<snippet json file 2>...]
And similarly, if you already have a workflow defined in a snippet, you can easily share it by exporting via (without title will yield interactive title selection)
corgi export [<title of the snippet>] [-o <output file path>]
and send the json file to another person
You can remove a snippet by running (without title will yield interactive title selection)
corgi remove [<title of the snippet>]
You can configure your text editor choice (default is vim
) for snippet editing, and filter tool for interactive snippet selection. To configure the corgi CLI, run
corgi config [--editor <editor of your choice>] [--filter-cmd <fzf, peco or something else>]
Here are some features that are currently on the roadmap:
- Support concurrent execution of steps
- Support remote server configuration, so that snippet can run seamlessly on a remote computer
Corgi is inspired by Pet, and aims to advance Pet's command-level usage to a workflow level.