Skip to content

Add "Filter Through Shell Command" feature#3892

Open
kanocz wants to merge 1 commit into
lapce:masterfrom
kanocz:shell-filter
Open

Add "Filter Through Shell Command" feature#3892
kanocz wants to merge 1 commit into
lapce:masterfrom
kanocz:shell-filter

Conversation

@kanocz
Copy link
Copy Markdown

@kanocz kanocz commented Apr 12, 2026

  • Added an entry to CHANGELOG.md if this change could be valuable to users

Summary

  • Add a command to pipe the current editor selection through an external shell command (stdin → command → stdout replaces selection)
  • Works with local and remote (SSH) workspaces — command execution goes through the proxy RPC
  • Supports single selection only (Insert, Normal, and Visual cursor modes)
  • Palette-based UI with command history and configurable options (output to new document, timeout)

Details

New command "Filter Through Shell Command" accessible via the command palette. When triggered, a palette opens where the user can type a shell command or pick from previously used ones. The current selection is sent as stdin to the command, and stdout replaces the selection. If nothing is selected, stdout is inserted at the cursor position.

Options available as toggles in the palette UI:

  • New document — output to a new scratch document instead of replacing the selection
  • Timeout — configurable timeout (5/10/30/60 seconds, default 5s)

Files changed

  • lapce-rpc/src/proxy.rs — new FilterThroughShell request/response in the RPC protocol
  • lapce-proxy/src/dispatch.rs — shell execution handler with timeout (cross-platform: sh -c / cmd /C)
  • lapce-app/src/command.rs — workbench command and internal command variants
  • lapce-app/src/palette/kind.rs, item.rs — new palette kind and item type
  • lapce-app/src/palette.rs — command history, option signals, palette population and selection logic
  • lapce-app/src/window_tab.rs — command dispatch, async RPC bridge, selection replacement / new document creation
  • lapce-app/src/app.rs — palette item rendering and options toggle row

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant