Skip to content

docs / get

cwm get

Find a saved command, copy it, show it, or run it. Also searches shell history.

$ cwm get [name|id] [flags]

How it works

  • With a name, get copies the command to the clipboard. With no name it lists commands and asks you to pick one.
  • -x runs the command. With the shell wrapper from cwm setup it runs in your current shell, and the exit code of the command is passed through.
  • --show prints only the command on stdout. Tables, prompts and errors go to stderr, so it is safe to pipe.
  • Placeholders written as %name% or {{name}} are filled in by prompts. Comment lines are ignored.
  • -f turns on fuzzy matching: the letters you type must appear in order, not next to each other.
  • History search (-h) reads your shell history file. -a reads what cwm watch recorded for the current folder.

Flags

-x, --exec
Run the command instead of copying it.
--show
Print the command without copying it.
-l, --list
List commands without asking for a choice.
-t, --tag <tag>
Only commands with this tag.
-f, --fuzzy
Fuzzy search saved commands or history.
-h, --hist
Search shell history.
-a, --active
Search commands recorded in the current project folder.
-c, --copy
Read from the copy bank database.
-n, --count <n>
Limit the number of results. History default is 10.

Examples

List everything

cwm get
$ cwm get -l
Saved Commands
ID     Variable         Command                              Tags             Description
-----------------------------------------------------------------------------------------------
1      hello            echo Hello World                     util             Greets user
2      deploy           kubectl rollout restart deploy/%...  k8s              Restart a deployment
3      gs               git status -sb                       git

Show a command without copying

cwm get
$ cwm get hello --show
echo Hello World

Run a command

cwm get
$ cwm get hello -x
Description: Greets user
Executing command: echo Hello World
Hello World

Unknown name

cwm get
$ cwm get nope --show
Error: Command 'nope' not found.

Browse shell history

cwm get
$ cwm get -h
System Shell History (6/6)
ID     Command
----------------------------------------------------------------------
1      npm install
2      git commit -m "feat: setup GoReleaser"
3      ls
4      git commit -m "fix: database schema"
5      docker compose up -d
6      git status
 
Copy (ID):

Commands recorded in this folder

cwm get
$ cwm get -a -l
Local Project History (3/3)
ID     Command
----------------------------------------------------------------------
1      git status
2      git commit -m feat
3      npm run build