Command-Line Interface
The CodeFetch CLI is how you execute scripts on target machines. It runs anywhere you have a terminal — servers, containers, CI pipelines, or your own laptop. Everything is one command away.
Install
Linux / macOS
curl -fsSL https://github.com/codefetch-io/codefetch-releases/releases/latest/download/install.sh | bash
Windows (PowerShell, run as Administrator)
iwr https://github.com/codefetch-io/codefetch-releases/releases/latest/download/install.ps1 | iex
Run the same command again at any time to upgrade to the latest version.
Configure
codefetch config
Enter your API endpoint (account URL) and secret key when prompted. The configuration is saved as an encrypted file bound to your machine's hardware ID, hostname, and username.
To clear saved configuration and start fresh:
codefetch config --reset
Interactive library browser
codefetch list
Running codefetch with no arguments opens the same screen. The browser loads your full library and stays open until you act or quit.
Navigation
| Key | Action |
|---|---|
↑ / ↓ | Move selection |
PgUp / PgDn | Page through results |
| Type anything | Filter by ID, filename, summary, or tags |
Backspace | Delete filter characters |
Esc | Clear filter / quit |
Actions on selected script
| Key | Action |
|---|---|
Ctrl+X | Execute the script |
Ctrl+O | Save to a local temp file (copies path to clipboard) |
Ctrl+S | Source into the current shell session |
Ctrl+H | Open the help screen |
Shared link management
The right-hand detail panel shows shared link status for the selected script. Links can be created, rotated, and deleted without leaving the browser.
| Key | Action |
|---|---|
Ctrl+L | Create or rotate the shared link |
Ctrl+D | Delete the shared link |
Ctrl+Y | Push to Shorty (if configured) |
Run a script by ID
codefetch get <ID>
Fetches the script from your library, decrypts it, and executes it on the current machine.
Save locally instead of executing
codefetch get <ID> --save
Downloads the script to a local temp file and copies the path to the clipboard. Useful for inspecting before running.
Source into the current shell session
Loads functions or environment variables into your current terminal without spawning a subshell.
Bash:
eval "$(codefetch get <ID> --source)"
PowerShell:
. ([scriptblock]::Create( (codefetch get <ID> --source) -join "`n" ))
Run from a shared link
codefetch link <URL>
No account, endpoint, or secret required. Useful for running scripts on unconfigured machines or sharing with people who don't have a CodeFetch account.
The --save and --source flags work the same way as with codefetch get.
Search by tags
codefetch search <tags>
Returns all library items matching the given tags. Comma-separate multiple tags to narrow results.
Playbooks
Playbooks let you chain multiple scripts and run them in sequence with a single command.
Tag convention
Tag each script with a shared group tag and a sequence number:
deploy-prod, #1
deploy-prod, #2
deploy-prod, #3
Export a playbook
codefetch playbook export <tag> /path/to/playbook.json
Searches your library by tag and exports the results to a JSON file in execution order.
Run a playbook
codefetch playbook run /path/to/playbook.json
Scripts are fetched and executed in sequence. Each script runs to completion before the next begins. Store the JSON file in your repo so it can be versioned alongside your infrastructure code.
CI/CD and automation
Pass credentials at runtime instead of relying on a local config file. Useful in pipelines where you can't run codefetch config interactively:
codefetch get <ID> --auth-uri <URI> --auth-secret <SECRET>
Store the URI and secret as environment variables or secrets in your CI provider:
codefetch get <ID> --auth-uri "$CODEFETCH_URI" --auth-secret "$CODEFETCH_SECRET"
The --auth-uri and --auth-secret flags also work with playbook run.
Shell completion
Generate a completion script for your shell so you can tab-complete codefetch commands and flags.
codefetch completion <shell>
Supported shells: bash, zsh, fish, powershell.
Bash
codefetch completion bash | sudo tee /etc/bash_completion.d/codefetch
source /etc/bash_completion.d/codefetch
Zsh
codefetch completion zsh > "${fpath[1]}/_codefetch"
Then start a new shell session for completions to take effect.
Fish
codefetch completion fish > ~/.config/fish/completions/codefetch.fish
PowerShell
codefetch completion powershell >> $PROFILE
Then restart PowerShell for completions to take effect.
Quick reference
| Task | Command |
|---|---|
| Configure | codefetch config |
| Browse library | codefetch list |
| Run by ID | codefetch get <ID> |
| Run from shared link | codefetch link <URL> |
| Search by tags | codefetch search <tags> |
| Save locally | codefetch get <ID> --save |
| Source into session | eval "$(codefetch get <ID> --source)" |
| Export playbook | codefetch playbook export <tag> <file> |
| Run playbook | codefetch playbook run <file> |
| Runtime auth | codefetch get <ID> --auth-uri <URI> --auth-secret <SECRET> |
| Reset config | codefetch config --reset |
| Shell completion | codefetch completion <bash|zsh|fish|powershell> |
| Version | codefetch version |