# trimmy
> Flatten multi-line shell snippets into single pasteable commands

## 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

## When to Use
- 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

## When NOT to Use
- Running on non-macOS platforms
- Working with intentionally multi-line scripts that should not be flattened
- 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

## Installation
- **homebrew**: `brew install --cask steipete/tap/trimmy`
- **source**: `swift build -c release`

---
Source: https://littlescripts.sh/tools/trimmy
