repobenchmarks // terminal ui tools
CLI TOOLS
$ gum choose "Deploy Staging" "Deploy Production"

gum: Glamorous Shell Scripts

A collection of composable CLI utilities from Charm that adds beautiful TUI elements to bash scripts with zero programming knowledge.

Components: choose, input, filter, spin, confirm Language: Go (Bubble Tea) Stars: >18,000
? Select target environment: > Production (v2.4.0) Staging (v2.4.1-rc) Local Docker Compose

Writing internal operational scripts for deployments, database backups, or onboarding new developers usually results in ugly shell scripts full of awkward read -p "Are you sure? (y/n)" prompts. If you want fuzzy searching or spinners, you historically had to write full programs in Python or Go. gum (by Charmbracelet) brings the power of modern TUI frameworks to plain shell scripts via single, composable CLI commands.

5 Essential `gum` Commands for Shell Scripts

1. Interactive Menus with `gum choose`

ENV=$(gum choose "Development" "Staging" "Production")
echo "Selected environment: $ENV"

2. Fuzzy Autocomplete with `gum filter`

Pipe any list of items into gum filter to let the user search interactively:

BRANCH=$(git branch --format="%(refname:short)" | gum filter)
git checkout "$BRANCH"

3. Beautiful Spinners for Long-Running Tasks

gum spin --spinner dot --title "Compiling release binary..." -- cargo build --release

4. Confirmation Modals

if gum confirm "Are you sure you want to drop the database?"; then
  dropdb myapp_db
fi

gum Scripting Composition Model

gum Shell Script Composition Pipeline Shows standard bash stdout piping through gum interactive widgets to populate shell variables cleanly. Standard stdout docker ps --format gum filter Interactive TUI search Terminal /dev/tty Bash Variable CONTAINER_ID="78ab31"

gum vs Traditional Shell Prompting

Capability gum Standard Bash (`read`)
Menu Selection Arrow-key navigation + checkboxes Type index number manually
Fuzzy Filtering Built-in fuzzy search buffer Requires manual fzf scripting
Password Masking `gum input --password` `read -s` (No visual feedback)
⚠ Subshell Pipeline Gotcha: TTY Redirection

When running gum inside automated CI/CD pipelines or automated cron jobs where no interactive terminal (TTY) is attached, commands like gum choose or gum confirm will fail with a "not a tty" error. Always test whether standard input is interactive (using [ -t 0 ]) before invoking gum in production deployment scripts.

Explore all widgets and styling examples at the official Charm gum repository.