Skip to content

vlebo/ctx

Repository files navigation

ctx

Context switcher for DevOps

CI Go Reference GitHub release License: MIT


ctx is a CLI tool that simplifies working across multiple cloud environments, projects, and infrastructure platforms. Switch between AWS profiles, Kubernetes clusters, VPN connections, and SSH tunnels with a single command.

$ ctx list
NAME           ENVIRONMENT  CLOUD  ORCHESTRATION
acme-dev       development  aws    kubernetes
acme-staging   staging      aws    kubernetes
acme-prod      production   aws    kubernetes

$ ctx use acme-prod
✓ AWS profile: acme-prod (us-east-1)
✓ Kubernetes: prod-cluster/default
✓ VPN connected: wireguard (wg0)
✓ Tunnels: postgres, redis

[ctx: acme-prod] $

Features

Category Features
Cloud Providers AWS, GCP, Azure profile switching with auto-login support
Orchestration Kubernetes, Nomad, Consul context management
Networking SSH tunnels with auto-reconnect, per-tunnel management
VPN OpenVPN, WireGuard, Tailscale, custom commands
Secrets Bitwarden, 1Password, Vault, AWS Secrets Manager, AWS SSM, GCP Secret Manager
Identity Per-context Git user configuration
Registries Docker and NPM registry configuration
Browser Chrome/Firefox profile per context for SSO workflows
Shell Per-shell contexts, colored prompts, environment isolation
Inheritance Base/abstract contexts with multi-level inheritance

Quick Install

curl -fsSL https://github.com/vlebo/ctx/releases/latest/download/install.sh | sh

Add to your ~/.zshrc or ~/.bashrc:

eval "$(ctx shell-hook zsh)"   # for Zsh
eval "$(ctx shell-hook bash)"  # for Bash

Quick Start

# Initialize ctx
ctx init

# Create a context file at ~/.config/ctx/contexts/myproject-dev.yaml
cat > ~/.config/ctx/contexts/myproject-dev.yaml << 'EOF'
name: myproject-dev
description: "MyProject Development Environment"
environment: development

aws:
  profile: myproject-dev
  region: us-west-2

kubernetes:
  context: arn:aws:eks:us-west-2:123456789:cluster/dev
  namespace: default
EOF

# Switch to the context
ctx use myproject-dev

# Verify
ctx                          # Show current context status
aws sts get-caller-identity  # Using your AWS profile
kubectl get pods             # Connected to your cluster

Documentation

Full documentation is available at vlebo.github.io/ctx

Platform Support

Platform Status
Linux Full support
macOS Full support
Windows WSL required

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE for details.