Trimmy

steipeteMIT活跃维护

复制来的多行 shell 片段常带换行和缩进,粘到终端就跑不起来;Trimmy 在粘贴时自动压平成可直接执行的一行命令。

"Paste once, run once." — Trimmy flattens those multi-line shell snippets you copy so they actually paste and run.

v0.11.6发布于 2026-10-23 22:58 UTC749star +1 / 7 天42fork同步于 2026-11-10 17:56 UTC

怎么上手

由 README 提炼,执行前请确认
brew install --cask steipete/tap/trimmy
硬件要求按 README 说明

README 未说明显存或 GPU 要求;这是 macOS 菜单栏应用,需 macOS 15 及以上,安装包面向 Apple silicon Mac。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

macOS 菜单栏小工具,把复制来的多行 shell 片段压成一行,粘贴即可直接运行

复制来的多行 shell 片段常带换行和缩进,粘到终端就跑不起来;Trimmy 在粘贴时自动压平成可直接执行的一行命令。

核心能力

  • 监听剪贴板,按命令特征和灵敏度自动把多行命令合并为单行
  • 为通用应用和终端分别设置灵敏度,终端默认 Normal
  • 识别 Terminal、iTerm、Ghostty、Warp、kitty 等常见终端
  • 提供 Paste Trimmed 与 Paste Original 全局快捷键,可预览改动
  • 附带 TrimmyCLI 无头命令行,复用同一套裁剪引擎

容易踩的坑

Paste Trimmed 和 Paste Original 需要授予 macOS 辅助功能权限;自动裁剪默认在通用应用为 Low、终端为 Normal,普通文本可能不会被改写;从源码运行 CLI 需 Swift 6.3 工具链,且需在源码目录执行 swift run TrimmyCLI。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.11.6
  1. v0.11.6Trimmy 0.11.6最新正式版2026-10-23 · 2026-10-23 22:58 UTC

    Highlights: Preserve URL query bytes, recover cleanly from Start at Login failures, and avoid duplicate CLI newlines.

    • URL cleanup: preserve retained query fields exactly, including malformed percent escapes (#63, thanks @SebTardif).
    • Settings: show Start at Login failures with recovery guidance, restore failed toggle changes, and preserve the saved choice when startup registration fails (#63, thanks @SebTardif).
    • CLI: avoid appending a duplicate final newline while keeping exit codes tied to actual text cleaning (#63, thanks @SebTardif).
  2. v0.11.5Trimmy 0.11.52026-10-21 · 2026-10-21 08:50 UTC
    查看更新说明
    • CLI: keep the standalone version synchronized with the app version and reject stale versions in CI before release.

    • Path quoting: quote only existing filesystem paths, preserving slash-containing prose and missing paths while supporting home-relative and relative paths with spaces (#57, thanks @SebTardif).

  3. v0.11.3Trimmy 0.11.32026-10-21 · 2026-10-21 03:23 UTC
    查看更新说明

    Highlights: Safer URL, shell-command, and Markdown cleanup without changing copied prose.

    • URL repair: preserve prose following a URL while retaining wrapped host, path, query, and fragment continuations (#58, thanks @SebTardif).
    • Text cleanup: preserve separate uppercase shell arguments and remove in-word backslash continuations without inserting a space (#59, thanks @SebTardif).
    • Text cleanup: preserve line breaks and prose spacing around box-drawing gutters, including Unicode separators and mixed-case remote hosts (#60, thanks @SebTardif).
    • Command detection: preserve prose that shares short command prefixes and filesystem notes such as /etc, while retaining real shell and namespaced slash commands (#61, thanks @SebTardif).
    • Text reflow: keep standalone hyphens spaced and rejoin wrapped Markdown links without changing inline code or parenthetical prose (#62, thanks @SebTardif).
    • Move macOS CI and release builds to xcode-27 while preserving macOS 15 support, native SwiftPM builds, and Linux Swift 6.3/6.4 coverage.
  4. v0.11.2Trimmy 0.11.22026-09-22 · 2026-09-22 12:12 UTC
    查看更新说明

    Highlights: Safer shell prompt cleanup, clearer CLI errors, and more reliable app updates.

    • Prompt cleanup: preserve shell variable references and Markdown headings whose words merely start with a command name.

    • CLI: report file, stdin, and UTF-8 decoding failures with their input source instead of incorrectly claiming that no input was provided.

    • URL cleanup: preserve content-identity parameters with percent-encoded names and leave URLs followed by other text untouched.

    • Updates: upgrade Sparkle to 2.10.0 for macOS 27 delta-update compression fixes and better download progress handling.

  5. v0.11.1Trimmy 0.11.12026-09-14 · 2026-09-14 01:55 UTC
    查看更新说明

    Highlights: macOS 27-ready shortcuts, clipboard restores that never clobber a newer copy, and CLI stdin/argument fixes.

    • Dependencies: update KeyboardShortcuts to 3.1.0 for macOS 27 compatibility, smoother menu highlighting, function-key handling, and shortcut recorder fixes.
    • Clipboard: use the latest copy for manual pastes and preserve all clipboard formats when restoring, without overwriting a newer copy.
    • Text reflow: preserve fenced content when a fence-like line has trailing text, and require valid Markdown numbered-list markers before rewriting lists.
    • Text cleanup: preserve literal path characters and home expansion, keep placeholder-like text intact when preserving blank lines, and recognize CRLF/CR command continuations.
    • Previews: mark removals correctly around emoji and inserted characters, and use the real cleanup engine for sensitivity examples.
    • Shortcuts: keep cleared paste shortcuts unset across restarts and show recorded function keys and keyboard-layout equivalents correctly in the menu.
    • CLI: correctly read --trim - from stdin, keep short options such as -f separate from file input, and report invalid arguments instead of silently ignoring them.
    • CLI installer: keep the app responsive during authorization and install correctly from paths containing shell characters, without a shared temporary script.
    • App lifecycle: release Accessibility polling and system copy-event hooks when their owners go away and disable Sparkle in signed development builds.
    • Build compatibility: Swift 6.3 or later is now required because Swift 6.2.4 crashes while compiling the updated shortcut dependency's isolated deinitializers; macOS 15 support is unchanged.
    • Dependencies: update KeyboardShortcuts to 3.0.1 for Swift 6 concurrency and release-build fixes.
    • Build: validate macOS and Linux with Swift 6.3 and 6.3.3, pin Actions and lint tools, and run portable text and packaging-script tests in CI.
    • Website: remove stale release numbers from download and social-card labels and clarify that clipboard processing stays local.
    • Development: reuse SwiftPM builds when packaging the debug app, simplify signed shortcut-resource packaging, and replace the obsolete Xcode project with the supported Package.swift workflow.

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Trimmy ✂️ — Paste once, run once.

    CI Latest release macOS 15+ License Homebrew

    Trimmy is a macOS menu-bar app that turns copied multi-line shell snippets into one pasteable command. It watches the clipboard and uses command cues plus configurable sensitivity to avoid rewriting ordinary prose and code.

    Trimmy menu showing Paste Trimmed and Paste Original to Ghostty

    printf '%s\n' \
      'Trimmy' \
      'is ready'
    # clipboard → printf '%s\n' 'Trimmy' 'is ready'
    

    Trimmy rewrites the copy once; your next paste is a single command.

    Install

    On an Apple silicon Mac running macOS 15 or later:

    brew install --cask steipete/tap/trimmy
    

    You can instead download the signed app from GitHub Releases. Sparkle checks for app updates after installation.

    Quick start

    1. Open Trimmy. The scissors icon appears in the menu bar.
    2. Copy the three-line printf command above.
    3. Paste into a terminal. Trimmy has changed the clipboard to one line, so the shell runs it once and prints:
    Trimmy
    is ready
    

    The default sensitivity is Low in general apps and Normal in terminals. Use Paste Original from the menu whenever you need the untouched copy.

    Terminal example showing a wrapped command flattened into one line

    Choose when Trimmy acts

    Trimmy uses separate sensitivity settings for general apps and terminals. It recognizes Terminal, iTerm, Ghostty, Warp, kitty, WezTerm, Hyper, Alacritty, and cmux, and you can exclude specific apps or browser sites from automatic trimming.

    LevelBehavior
    NoneDisables command flattening in general apps; optional text reflow still applies.
    LowRequires strong cues such as pipes, redirects, or \ continuations.
    NormalHandles typical multi-line commands with flags. This is the terminal default.
    HighFlattens most command-shaped text. Paste Trimmed always uses this level.

    Prompt gutters such as $ and # are removed when separated from a command by whitespace. Shell variable references such as $HOME/bin/tool and Markdown headings such as # GitHub Actions remain intact. Automatic trimming skips large clipboard blobs as a safety valve. Filesystem notes such as /etc are left alone. URL repair preserves same-line trailing prose and multiword prose lines, while still joining path, query, or fragment components copied as token-only continuation lines.

    Low and Normal sensitivity preserve YAML block scalars and their required indentation. High sensitivity and manual Paste Trimmed still flatten on request.

    Paste actions and permissions

    Paste Trimmed and Paste Original can be assigned global shortcuts. Clearing a shortcut keeps it unset after restarting Trimmy. Their menu previews name the target app and show what trimming removed before sending a paste keystroke. Manual pastes use the latest copy and temporarily replace the clipboard, then restore every available item and format unless another app has copied something newer.

    These paste actions need macOS Accessibility permission. Trimmy prompts for it when necessary and links to System Settings → Privacy & Security → Accessibility. Automatic clipboard rewriting still works without simulated paste access. If Start at Login cannot be changed, Settings shows the failure and recovery steps and restores the previous toggle. A failure at launch preserves your saved choice so it can be retried.

    Other cleanup actions

    Enable Settings → General → Automatically reflow copied text to join hard-wrapped prose and Markdown during Auto-Trim. It defaults off, respects app/site exclusions, and preserves headings, lists, paragraph breaks, and fenced code. Recognized source code and configuration are excluded. The manual Paste Reflowed Text action uses the same checks; optional removal of leading blank lines also defaults off. Recognized documents are reflowed before command cleanup so fenced examples stay intact. Closing fences require only trailing spaces or tabs, and numbered list markers require one to nine ASCII digits followed by a period or parenthesis and whitespace. Wrapped Markdown links are rejoined during text reflow, while inline code and parenthetical prose stay spaced. A separate action removes URL query parameters while retaining configured identity parameters such as YouTube video IDs, GitHub tabs, and Figma node IDs.

    Box-drawing gutters such as │ and ┃ can also be removed from copied terminal output without stripping real shell pipes. Paths containing spaces are quoted for the shell only when the complete path exists on this computer. Relative paths resolve from Trimmy’s working directory (the invoking directory for the CLI), and a leading ~/ resolves from your home directory. Quoting preserves literal dollar signs, backticks, backslashes, and quotes, while keeping ~/ outside the quotes so the shell can expand it. Nonexistent paths and slash-containing prose remain unchanged. Command continuations accept LF, CRLF, and CR line endings.

    Markdown reformatting example

    Headless CLI

    TrimmyCLI uses the same trimming engine without the menu-bar app. Run it from the source checkout:

    printf '%s\n' 'echo hello \' '  world' | swift run TrimmyCLI --trim --force
    

    The result is echo hello world. The packaged app can install trimmy from Settings → Advanced, and Linux binaries are attached to GitHub Releases.

    See the CLI reference for file input, JSON output, all options, and exit codes.

    How it works

    • A roughly 150 ms timer watches for pasteboard ownership changes, followed by an 80 ms grace period for promised clipboard data.
    • Clipboard writes carry a com.steipete.trimmy marker so Trimmy does not process its own output.
    • Clipboard content stays local. Trimmy has no telemetry or account system; its network use is Sparkle's update check.

    The technical specification covers the detection heuristics, settings, and pasteboard behavior in more detail.

    Development

    Trimmy requires Swift 6.3 and macOS 15 or later. Install a Swift 6.3 toolchain if your Xcode version bundles an older compiler.

    TrimmyCore owns the shared text-cleaning pipeline. Its tests and the CLI tests run on macOS and Linux; TrimmyTests covers the macOS clipboard and UI integration. SwiftPM includes app dependencies only on macOS.

    Open Package.swift in Xcode, or use the commands below. The build scripts select SwiftPM’s native backend to retain static Linux linking and the package layout on Swift 6.4. Debug packaging reuses the current SwiftPM build and signs a fresh app bundle; release packaging starts with a clean build.

    macOS CI and release builds use the default Xcode 27 toolchain on the Apple silicon xcode-27 runner, retaining the macOS 15 deployment target. Linux CI covers Swift 6.3 and 6.4.0. Lint uses SwiftFormat 0.63.0 and SwiftLint 0.65.1; Scripts/install_lint_tools.sh <directory> installs checksum-verified macOS lint binaries into a chosen directory.

    Scripts/install_swift_ci.sh installs exact official Swift releases in CI. It requires the macOS package's signer to be Swift Open Source (V9AUD2URP3) and verifies Linux archives against the pinned public Swift release key (52BB7E3DE28A71BE22EC05FFEF80A866B47A981F, from Swift's published keys). Review the signing identity when updating toolchains to a release signed by a different key.

    swift build --build-system native
    swift test --build-system native
    pnpm check
    ./Scripts/package_app.sh debug
    

    Related

    • trimmy.app is the project website.
    • Alfred Trimmy is a community Alfred workflow.
    • CodexBar keeps Codex token windows visible in the menu bar.
    • MCPorter is a TypeScript toolkit and CLI for Model Context Protocol servers.
    • Oracle is a multi-model prompt bundler and CLI.

    License

    MIT — built by Peter Steinberger in Vienna, with help from a small pair of scissors.