CLI Reference
Complete reference for all ctx commands.
Context Management
ctx
Show current context status.
Displays:
- Current context name
- Environment (development, staging, production)
- Active cloud providers
- Active orchestration (Kubernetes, Nomad)
- VPN status
- Running tunnels
ctx list
List available contexts.
ctx list # List usable contexts (hides abstract)
ctx list --all # List all contexts including abstract/base
Output columns:
NAME- Context name (abstract contexts prefixed with~)ENVIRONMENT- Environment typeCLOUD- Configured cloud providersORCHESTRATION- Configured orchestrators
ctx use <name>
Switch to a context.
ctx use myproject-dev # Switch to context
ctx use myproject-prod --confirm # Switch to production (skip confirmation)
ctx use myproject-prod --replace # Switch and deactivate previous context
Flags:
| Flag | Description |
|---|---|
--confirm |
Skip production confirmation prompt |
--replace |
Deactivate previous context before switching |
What happens:
- Validates context exists and is not abstract
- If production, prompts for confirmation (unless
--confirm) - Sets environment variables
- Connects VPN (if
auto_connect: true) - Starts tunnels (if
auto_connect: true) - Runs auto-login for cloud providers (if configured)
- Fetches secrets and injects as environment variables
ctx show <name>
Show detailed context configuration.
For inherited contexts, shows the merged configuration.
ctx deactivate
Deactivate current context.
What happens:
- Clears context environment variables
- Disconnects VPN (unless
deactivate.disconnect_vpn: false) - Stops tunnels (unless
deactivate.stop_tunnels: false) - Keeps credentials for next activation
ctx logout [context]
Fully disconnect and clear all credentials.
What happens:
- Everything
ctx deactivatedoes - Removes stored tokens (Vault, etc.) from keychain
- Clears cached credentials
ctx init
Initialize ctx configuration.
Creates ~/.config/ctx/ directory structure.
SSH Tunnels
ctx tunnel list
List defined tunnels for current context.
ctx tunnel up [name]
Start tunnels.
ctx tunnel down [name]
Stop tunnels.
ctx tunnel status
Show running tunnel status.
VPN
ctx vpn connect
Connect VPN for current context.
ctx vpn disconnect
Disconnect VPN.
ctx vpn status
Show VPN connection status.
Browser
ctx browser list
List detected browser profiles.
ctx browser open [url]
Open browser with context profile.
Quick URLs
ctx open [name]
Open URLs defined in context.
Uses the configured browser profile if set.
Shell Integration
ctx shell-hook <shell>
Output shell integration script.
ctx shell-hook zsh # Output Zsh integration
ctx shell-hook bash # Output Bash integration
ctx shell-hook fish # Output Fish integration
Add to your shell config:
Deactivate vs Logout
| Command | VPN | Tunnels | Env Vars | Credentials |
|---|---|---|---|---|
ctx deactivate |
Disconnect* | Stop* | Clear | Keep |
ctx logout |
Disconnect | Stop | Clear | Remove |
*Configurable per-context via deactivate.disconnect_vpn and deactivate.stop_tunnels
Exit Codes
| Code | Meaning |
|---|---|
0 |
Success |
1 |
General error |
2 |
Context not found |
3 |
Abstract context (cannot use) |
4 |
Production confirmation declined |