← Back to tools

trimmy

Flatten multi-line shell snippets into single pasteable commands

Description

Trimmy is a macOS menu bar utility and CLI that automatically flattens multi-line shell snippets in the clipboard into single-line commands. It removes newlines while respecting backslash continuations, strips leading shell prompts, preserves Markdown headings, and offers configurable aggressiveness levels. Context-aware with terminal detection for app-specific behavior.

Install

homebrewbrew install --cask steipete/tap/trimmy
sourceswift build -c release

AI Summary

macOS menu bar utility and CLI that auto-flattens multi-line shell snippets in the clipboard into single pasteable commands. Strips prompts, respects backslash continuations, and offers configurable aggressiveness levels.

Capabilities

  • + Automatically monitor clipboard for multi-line shell commands and flatten them
  • + Remove newlines while respecting backslash line continuations
  • + Strip leading shell prompts ($ and #) from copied commands
  • + Preserve Markdown headings (lines starting with #)
  • + Configurable aggressiveness levels: none, low, normal, high
  • + Terminal-aware: auto-detects Terminal, iTerm, Ghostty, Warp, WezTerm, Alacritty, Hyper, kitty
  • + App-specific aggressiveness settings
  • + Remove box-drawing characters from styled terminal prompts
  • + CLI mode for scripted usage with JSON output
  • + Markdown paragraph reflowing

Use When

  • Copying multi-line shell commands from documentation, blogs, or READMEs
  • Pasting commands into terminals that do not handle multi-line input well
  • Stripping prompt characters from copied terminal output
  • Need a CLI tool to flatten shell snippets in automation pipelines

Avoid When

  • x Running on non-macOS platforms
  • x Working with intentionally multi-line scripts that should not be flattened
  • x The clipboard content is not shell commands (e.g., prose or code)

Usage Patterns

Flatten a file

swift run TrimmyCLI --trim /path/to/file --aggressiveness high --json

Flattens the multi-line content of a file and outputs JSON with original and trimmed text

Flatten clipboard content

pbpaste | swift run TrimmyCLI --trim - --force

Reads clipboard via pbpaste, flattens it with high aggressiveness

Input / Output

stdin: Multi-line shell snippet text (when using --trim -)
stdout: Flattened single-line command or JSON output
stderr: Error messages
Exit codes:
0 Success
1 No input or error
2 No transformation applied
3 JSON encoding error

Typical Pipelines

pbpaste | swift run TrimmyCLI --trim - --force | pbcopy
swift run TrimmyCLI --trim snippet.sh --aggressiveness high --json | jq .trimmed
View AGENTS.md for trimmy