tsilva avatar

bash-output-styler

Applies gorgeous terminal styling to bash scripts using gum with ANSI fallback.

version
2.0.0

Install

/plugin install bash-output-styler@claudeskillz

Run it inside Claude Code after adding the marketplace with /plugin marketplace add tsilva/claudeskillz.

Contents

Discovered from source

Skills 1

Bash Output Styling

Style all user-facing shell script output using the bundled style.sh library.

Workflow

  1. Read references/style.sh to understand available functions
  2. If style.sh doesn't exist alongside the target script, copy from references/style.sh into the same directory
  3. Source style.sh in the target script: source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/style.sh" 2>/dev/null || true
  4. Replace raw echo statements with styled output function calls
  5. Replace read -p prompts with confirm, input, or choose as appropriate
  6. Wrap long-running commands with spin for animated feedback
  7. Use table for structured multi-column data and progress for counted loops
  8. Verify script still works when style.sh is missing (graceful degradation)

Color Palette

NameHexANSI 256Use
Brand#AF87FF141Headers, emphasis
Success#87D787114Checkmarks, completion
Error#FF5F5F203Errors, failures
Warning#FFD75F221Warnings, caution
Info#87CEEB117Info messages, tips
Muted#808080244Paths, secondary text

Output Functions

FunctionSymbolColorPurpose
header "brand" "subtitle"boxBrandBordered header
section "text"━━BrandHorizontal rule divider (fills terminal width)
success "text"✓SuccessCompleted actions
error "text"✗ErrorError messages
warn "text"⚠WarningWarnings
info "text"●InfoInformational
step "text"→MutedAction log (suppressed when quiet)
note "text"—Muted"Note:" prefixed
banner "text"boxSuccessCompletion banner
error_block "lines..."│ErrorMulti-line error box
list_item "label" "value"•Brand+MutedKey-value display
dim "text"—MutedDe-emphasized text (suppressed when quiet)
table "h1,h2" "v1,v2" ...boxBrand+MutedFormatted table with headers
progress cur total [label]████░░BrandInline progress bar

Interactive Functions

FunctionReturnsPurpose
confirm "prompt" [timeout] [affirm] [neg]Sets REPLYy/n prompt (backward-compatible)
spin "title" command [args...]Exit codeAnimated spinner wrapping a command
choose "header" "opt1" "opt2" ...stdoutInteractive selection menu
input "prompt" [placeholder] [--password]stdoutStyled text input

Pattern Mapping

Old PatternNew Pattern
echo "Title" + echo "====="header "Title" "Subtitle"
echo "✓ done"success "done"
echo "Error: ..."error "..."
echo "Warning: ..."warn "..."
echo " - Label: value"list_item "Label" "value"
read -p "Continue? (y/n) "confirm "Continue?"
echo "Section..." between blockssection "Section"
echo "Note: ..."note "..."
Multi-line error blockerror_block "line1" "line2"
select opt in ... / numbered menuchoose "Pick one:" "A" "B" "C"
read -p "Name: "input "Name:" "placeholder"
Long command with no feedbackspin "Installing..." brew install pkg
Aligned columns / status tablestable "Name,Status" "jq,installed"
Counter loop with echo progressprogress $i $total "Processing"

Environment Variables

VariableDefaultEffect
NO_COLORunsetDisables all color output when set to any value
STYLE_VERBOSE10=quiet (suppresses step/dim), 1=default, 2=verbose
COLORTERMunsetSet to truecolor or 24bit to enable RGB color palette

Rules

  • ALWAYS source style.sh with fallback: source "$SCRIPT_DIR/style.sh" 2>/dev/null || true
  • NEVER import gum directly in scripts — style.sh handles tool detection
  • NEVER hard-code ANSI codes in scripts — use style.sh functions exclusively
  • confirm function sets REPLY variable, compatible with existing [[ $REPLY =~ ^[Yy]$ ]] checks
  • spin returns the wrapped command's exit code — use in conditionals: if spin "Building..." make; then ...
  • choose and input return values via stdout — capture with: result=$(choose "Pick:" "A" "B")
  • Do NOT wrap instant operations with spin — only use for commands that take noticeable time
  • Interactive functions (choose, input, confirm) require a TTY — they read from /dev/tty
  • Preserve all existing logic — only change output formatting, never behavior
  • Scripts must work identically when style.sh is missing (plain echo fallback)

Sponsors

Details

Marketplace
tsilva/claudeskillz
Source
plugins/bash-output-styler
Category
Community

More from tsilva/claudeskillz

All 5