Command-Line Interface

Fetch and execute scripts from any machine — Linux, macOS, Windows.

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

KeyAction
/ Move selection
PgUp / PgDnPage through results
Type anythingFilter by ID, filename, summary, or tags
BackspaceDelete filter characters
EscClear filter / quit

Actions on selected script

KeyAction
Ctrl+XExecute the script
Ctrl+OSave to a local temp file (copies path to clipboard)
Ctrl+SSource into the current shell session
Ctrl+HOpen 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.

KeyAction
Ctrl+LCreate or rotate the shared link
Ctrl+DDelete the shared link
Ctrl+YPush 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" ))
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.

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

TaskCommand
Configurecodefetch config
Browse librarycodefetch list
Run by IDcodefetch get <ID>
Run from shared linkcodefetch link <URL>
Search by tagscodefetch search <tags>
Save locallycodefetch get <ID> --save
Source into sessioneval "$(codefetch get <ID> --source)"
Export playbookcodefetch playbook export <tag> <file>
Run playbookcodefetch playbook run <file>
Runtime authcodefetch get <ID> --auth-uri <URI> --auth-secret <SECRET>
Reset configcodefetch config --reset
Shell completioncodefetch completion <bash|zsh|fish|powershell>
Versioncodefetch version