| summary | Trimmy product/technical spec: goals, heuristics, settings, and build notes. | |||
|---|---|---|---|---|
| read_when |
|
- macOS 15+ menu-bar utility that watches the pasteboard for copied terminal commands and automatically flattens line breaks to make commands pasteable in one go.
- Avoids mangling non-command text via heuristics and user-configurable aggressiveness for general apps and terminals.
- Clipboard watcher polls
NSPasteboard.generalvia a GCDDispatchSourceTimer(~150ms, small leeway) to detect ownership changes promptly and rewrites text in-place when it detects shell-like multi-line content. - Detection heuristics score copied text based on:
- Presence of newlines / backslash line continuations
- Pipes/
&&/|tokens - Prompt
$prefixes - "Command-looking" leading tokens (incl. sudo)
- All lines resembling command syntax
- Aggressiveness levels (user setting):
- General apps: None / Low / Normal / High (default: Low).
- Terminals: Low / Normal / High (default: Normal).
- Context-aware trimming applies the terminal level when a terminal app is detected.
- Blank-line handling (checkbox): when enabled, empty lines are preserved during flattening; otherwise all newlines collapse to spaces.
- Auto-trim toggle: enable/disable automatic rewrite without quitting the app; manual "Paste Trimmed" works regardless and does not permanently alter the clipboard.
- Self-write marker: Trimmy writes an extra pasteboard type (
com.steipete.trimmy) so subsequent polls can ignore its own writes and only react to user changes. - Grace delay: small (~80ms) deferred read after detecting a changeCount bump to allow promised/late pasteboard data to become available; skipped if changeCount moves again.
- Robust text read: prefers
NSPasteboard.string(forType: .string)and normalizes line endings; the optional compatibility setting enables additional text representations. - UI
- Menu bar icon/text "Trimmy" with menu items: Auto-Trim toggle, "Paste Trimmed", "Paste Reflowed Text" (when wrapped prose or Markdown is detected), "Paste Original", status line showing last action preview, Quit.
- General settings control automatic text reflow (default off), removal of leading blank lines during reflow (default off for compatibility), and visibility of the manual reflow paste action (default on).
- Manual and automatic reflow share a fence-aware eligibility check that rejects recognized unfenced code and configuration. Automatic reflow runs before command cleanup, preserving fenced examples regardless of command sensitivity; None disables command flattening, not explicitly enabled reflow. The watcher toggle and app/site exclusions still gate automatic reflow. Manual Paste Trimmed retains its forced-command behavior.
- Reflow eligibility is heuristic, as with command detection. Short record-like fields favor preserving line boundaries; ordinary sentence-like comma clauses remain eligible. Untyped plain text can be ambiguous between prose and delimited data, so this is not universal file-format detection.
- SwiftUI Settings window (macOS-standard Settings scene) organized into General, Trimming, Rules, Shortcuts, Advanced, and About tabs.
- Trimming contains sensitivity pickers for General apps and Terminals plus cleanup behavior.
- Rules contains auto-trim app/site exclusions and URL content-identity parameter rules.
- Last action preview: menu shows truncated (~70 chars) version of last trimmed command.
- Accessory app: no Dock icon, lives in menu bar; quit from menu.
- Accessibility permission UX: when Accessibility is missing, Trimmy blocks paste commands and shows actionable callouts (menu + Settings) to trigger the system prompt and open the Privacy & Security › Accessibility pane.
- CLI helper: Settings → Advanced exposes an installer that symlinks the bundled helper into
/usr/local/binand/opt/homebrew/binastrimmyfor headless use. - URL query cleanup accepts a single bare HTTP(S) URL, allowing surrounding whitespace but rejecting whitespace within the input. Preservation rules match parameter names after one percent-decoding pass; retained names and values keep their original percent encoding.
- Platform: macOS 15.0+; Swift 6; SwiftUI for UI and settings; AppKit for pasteboard access.
- Performance: lightweight polling; avoid excessive CPU; operations on main actor for UI safety.
- Privacy: clipboard data stays local; Sparkle checks for updates, with no telemetry or account system.
SwiftPM defines the app, portable core, CLI, and test targets. Open Package.swift in Xcode, or use swift build and swift test from the checkout. Scripts/compile_and_run.sh builds, tests, packages and launches the signed development app. Scripts/package_app.sh [debug|release] emits Trimmy.app; debug packaging is incremental and release packaging starts clean.
The app runs as an accessory (LSUIElement) and uses SMAppService for its Start at Login preference. See the release checklist for authorized distribution work.