Skip to content

Getting Started

This guide will help you set up ctx and create your first context.

Installation

Quick Install

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

From Source

git clone https://github.com/vlebo/ctx.git
cd ctx
go build -o ctx ./cmd/ctx
sudo mv ctx /usr/local/bin/

Shell Integration

Add to your shell configuration file:

eval "$(ctx shell-hook zsh)"
eval "$(ctx shell-hook bash)"
ctx shell-hook fish | source

This enables:

  • Context name in your prompt: [ctx: myproject-prod]
  • Automatic environment variable loading on ctx use
  • Per-shell context isolation
  • Auto-load last context in new shells (can be disabled)

Disable Auto-Load in New Shells

By default, new shell sessions automatically load the last active context. To disable this and start fresh:

  1. Run ctx shell-hook to see the generated code
  2. Find and comment out the auto-load section at the bottom

Initialize ctx

ctx init

This creates the configuration directory at ~/.config/ctx/.

Create Your First Context

Create a file at ~/.config/ctx/contexts/myproject-dev.yaml:

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

Switch Context

ctx use myproject-dev

Verify

# Show current context status
ctx

# Test AWS
aws sts get-caller-identity

# Test Kubernetes
kubectl get pods

What's Next?