Gum — A Tool for Glamorous Shell Scripts by Charm
Gum is a CLI toolkit for building interactive shell scripts with spinners, prompts, file pickers, tables, and styled output — turning bash scripts into modern TUI experiences.
Instalación con revisión previa
Este activo requiere revisión. El prompt copiado pide dry-run, muestra escrituras y continúa solo tras confirmación.
npx -y tokrepo@latest install 43c00283-38c4-11f1-9bc6-00163e2b0d79 --target codexPrimero dry-run, confirma las escrituras y luego ejecuta este comando.
What it is
Gum is a command-line toolkit by Charm for building interactive shell scripts. It provides standalone commands for spinners, confirmation prompts, text inputs, file pickers, tables, and styled output. Each command is a single binary call you pipe into or compose with standard shell constructs.
Gum is for shell script authors who want to add interactivity without switching to a full TUI framework. If you write bash scripts for developer tooling, onboarding flows, or CI prompts, Gum makes them polished and user-friendly with minimal code.
How it saves time or tokens
This workflow provides the installation command and ready-to-use Gum recipes. Instead of building interactive prompts from scratch with read and select, you get single-line commands that handle input validation, styling, and user experience. The interactive commit message recipe alone replaces a multi-line bash function.
How to use
- Install Gum:
brew install gum
- Use Gum commands in your shell scripts:
# Interactive selection
TYPE=$(gum choose feat fix docs style refactor test chore)
# Text input with placeholder
SCOPE=$(gum input --placeholder 'scope')
# Multi-line text area
DESC=$(gum write --placeholder 'Describe your changes...')
# Confirmation
gum confirm 'Deploy to production?' && deploy
- Combine commands for complex flows:
# Interactive git commit
git commit -m "$TYPE($SCOPE): $DESC"
Example
#!/bin/bash
# Interactive project setup script using Gum
NAME=$(gum input --placeholder 'Project name')
LANG=$(gum choose 'TypeScript' 'Python' 'Go' 'Rust')
FEATURES=$(gum choose --no-limit 'CI/CD' 'Docker' 'Linting' 'Testing')
gum confirm "Create $LANG project '$NAME'?" || exit 0
gum spin --title "Setting up $NAME..." -- sleep 2
echo "Project $NAME created with: $FEATURES" | gum format
# File picker for log analysis
LOG=$(gum file /var/log/)
gum pager < "$LOG"
Related on TokRepo
- Automation tools -- Shell scripting and automation workflows
- AI coding tools -- Developer productivity tools
Common pitfalls
- Gum requires a terminal that supports ANSI escape codes. Piping Gum output through non-TTY contexts (like cron jobs or CI without pseudo-TTY) disables interactivity.
- The
gum choose --no-limitflag allows multiple selections but returns them on separate lines. Usewhile reador array assignment to capture multiple values. - Gum's styled output depends on terminal color support. In minimal containers or SSH sessions without TERM set, styling may not render.
Preguntas frecuentes
Gum adds interactive UI components to shell scripts. It provides commands for text input, selection menus, confirmation dialogs, spinners, file pickers, and styled text output. Each is a standalone binary you call from bash.
Yes. Gum is available via Homebrew on macOS, as a .deb and .rpm package on Linux, and as a standalone binary. It also works on Windows via Scoop or direct download.
Gum works in CI if you provide default values or skip interactive prompts. In non-interactive contexts, use flags like --value for gum input or pipe choices via stdin. Without a TTY, interactive selection is not available.
Charm is a company that builds open-source terminal tools in Go. Their ecosystem includes Gum (shell scripts), Bubbletea (Go TUI framework), Lipgloss (Go terminal styling), and Charm Cloud. All focus on making terminals more expressive.
Use gum style with flags like --foreground, --background, --bold, --italic, and --border. You can also pipe text through gum format for automatic markdown-like formatting in the terminal.
Referencias (3)
- Gum GitHub— Gum is a CLI toolkit by Charm for interactive shell scripts
- Charm Homepage— Charm builds open-source terminal tools in Go
- Gum README— Commands for spinners, prompts, file pickers, and styled output
Relacionados en TokRepo
Discusión
Activos relacionados
Bubble Tea — Powerful TUI Framework for Go
Bubble Tea is a powerful little TUI framework for Go based on The Elm Architecture. Build terminal applications with composable components, events, and commands. Part of the Charm ecosystem (Lip Gloss, Gum, Wish, Huh). Powers lazygit, soft-serve, and many CLI tools.
zx — Write Better Shell Scripts in JavaScript
A tool by Google for writing shell scripts using JavaScript with built-in support for command execution, pipes, and popular CLI utilities like cd, fetch, and chalk.
ShellCheck — A Static Analysis Tool for Shell Scripts That Finds Bugs Before You Ship
ShellCheck is the linter every shell script author needs. It catches unquoted variables, missing error handling, portability issues, and the hundred other ways bash can silently destroy your weekend.
Elvish — Expressive Programming Shell for the Modern Terminal
Elvish is a cross-platform shell that combines a powerful scripting language with a modern interactive experience including structured data pipelines, a built-in file manager, and persistent shared command history.