-
Notifications
You must be signed in to change notification settings - Fork 2
Compose
Gubarz edited this page May 20, 2026
·
1 revision
The compose subcommand converts a raw shell command into a reusable CheatMD snippet. It automatically extracts variables and writes a complete metadata block.
Pass a command as an argument:
cheatmd compose "curl -X POST <url> -H 'Auth: $token'"Or pipe a command through stdin:
echo "ssh -p $port $user@$host" | cheatmd compose -n "SSH Connect"compose detects both $ ($url) and angle bracket (<url>) variable syntax. It deduplicates the names and generates a <!-- cheat --> block:
# Snippet
<!-- cheat
var url
var token
-->
` + "```" + `sh
curl -X POST <url> -H 'Auth: $token'
` + "```" + `| Flag | Description | Default |
|---|---|---|
-n, --name
|
Header name for the cheat | "Snippet" |
-d, --description
|
Optional description below the header | (empty) |
-f, --file
|
Target save location | (auto) |
-p, --print
|
Print to stdout instead of saving |
false |
If --file is not provided, compose uses the first path in your cheatmd.yaml path setting:
- If it is a directory, it appends to
snippets.mdinside that directory. - If it is a file, it appends directly to that file.