Shell Functions¶
Functions are organized by domain across four files in ~/.config/zsh/functions/.
General (general.zsh)¶
cm — Chezmoi Shortcut¶
cm # Navigate to chezmoi source directory
cm apply # Forwards to: chezmoi apply
cm diff # Forwards to: chezmoi diff
af — AWS Profile Switcher¶
Interactive AWS profile selector with SSO login:
- Lists all AWS profiles via
fzf - Exports
AWS_PROFILE - Attempts
aws sts get-caller-identity - If session expired, triggers
aws sso login - Displays account and user info on success
gh-browse — GitHub Repo Browser¶
Uses gh CLI and fzf to select and open repos.
PostgreSQL Docker Helpers¶
Spin up PostgreSQL instances in Docker for local development:
| Function | Usage | Description |
|---|---|---|
pg_up |
pg_up [port] [version] [name] [db] [user] [pass] |
Start a PostgreSQL container |
pg_down |
pg_down [name] |
Stop container |
pg_status |
pg_status [name] |
Show container status |
pg_logs |
pg_logs [name] [lines] |
View logs |
pg_exec |
pg_exec [name] [db] [user] |
Open psql shell |
pg_backup |
pg_backup [name] [db] [user] [file] |
Backup database |
pg_restore |
pg_restore [name] [db] [user] <file> |
Restore from backup |
pg_list |
pg_list |
List all PostgreSQL containers |
pg_shell |
pg_shell [name] |
Bash into container |
pg_help |
pg_help |
Show help |
Defaults: port 5432, PostgreSQL 17, container postgres-dev, db devdb, user devuser, password devpass.
# Quick start with defaults
pg_up
# Custom setup
pg_up 5433 16 myproject mydb myuser mypass
# Backup and restore
pg_backup myproject mydb myuser ./backup.sql
pg_restore myproject mydb myuser ./backup.sql
cloner — Clone All Org Repos¶
Clones all repositories from a GitHub organization.
git_mirror_to_org — Mirror Repos Between Orgs¶
Mirrors a repository from one GitHub org to another.
Keychain Helpers¶
Wrappers around macOS security for storing and retrieving secrets in the system keychain:
| Function | Usage | Description |
|---|---|---|
keyring-set |
keyring-set <service> [value] |
Store a secret (prompts for hidden input if value omitted) |
keyring-get |
keyring-get <service> |
Retrieve a secret |
keyring-del |
keyring-del <service> |
Delete a secret |
# Store a secret (prompted, hidden input)
keyring-set anthropic-api-key
# Store inline
keyring-set anthropic-api-key sk-ant-...
# Retrieve
keyring-get anthropic-api-key
# Delete
keyring-del anthropic-api-key
Used by mise configs to inject secrets as environment variables without storing them in plaintext. See Claude Code — Dual Account Setup.
eks_config — Configure EKS Kubeconfig¶
Adds an EKS cluster to kubeconfig with an optional alias.
Kubernetes (kubectl.zsh)¶
kdebug — Debug Pod¶
Launch an ephemeral debug pod:
kdebug # busybox in default namespace
kdebug -n kube-system # busybox in kube-system
kdebug -i nicolaka/netshoot # custom image
kdebug -- curl http://my-svc # run a command
kadmin — Admin Pod¶
Launch a netshoot pod for network debugging:
kadmin # netshoot in default namespace
kadmin -n kube-system # in specific namespace
kadmin -- dig kubernetes.default # run DNS lookup
kclean — Delete Pods by Status¶
kpodbynode — Pods on a Node¶
kpodbylabel — Pods by Label¶
kremovefinalizers — Remove Finalizers¶
Removes all finalizers from a stuck resource to allow deletion.
kdelete_namespaces_with_prefix — Bulk Namespace Delete¶
Finds and deletes all namespaces matching a prefix (with confirmation).
kdelete_empty_namespaces — Clean Empty Namespaces¶
kdelete_empty_namespaces # Interactive confirmation
kdelete_empty_namespaces --yes # Skip confirmation
kdelete_empty_namespaces --prefix test- # Only matching prefix
inline_kubectl_editor — Inline Resource Editor¶
inline_kubectl_editor create # Create resource from inline YAML
inline_kubectl_editor apply # Apply inline YAML
Opens an inline editor for quick Kubernetes manifest editing.
Terraform (terraform.zsh)¶
Helper functions assume this directory structure:
tf_init — Initialize with Backend¶
tf_init mystack dev
# Runs: terraform init -reconfigure -backend-config=environments/dev.s3.tfbackend
tf_plan — Plan with Variables¶
tf_apply — Apply with Variables¶
tf_destroy — Destroy with Variables¶
clean_terraform — Clean Up¶
Talos (talos.zsh)¶
Functions for managing Talos Linux clusters.
tx — Switch Context¶
txf — Interactive Context Switcher¶
tdash — Dashboard¶
tdmesg — Kernel Messages¶
tuptime — Node Uptime¶
Shows uptime in human-readable format (days, hours, minutes).