Install
Install with PiG
pig install npm:@penumbral-labs/pi-copy-codeInstall with Pi
pi install npm:@penumbral-labs/pi-copy-codePackages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.
Pi manifest JSON
The pi field of package.json.
{
"extensions": [
"./extensions/copy-code/index.ts"
]
}README
Written by the package's publisher, shown as published in version 0.4.0 (README.md). PiG does not review it.
pi-copy-code
A Pi package for copying fenced code blocks and quoted text from assistant messages without terminal-selection padding.
pi-copy-code adds /copy-code and shortcuts for copying the raw text of recent assistant code blocks or Markdown
blockquotes. A single block copies immediately. Multiple blocks or responses open a two-pane picker with a live preview
and access to the last ten assistant responses containing matching content.
Prerequisites
- Node.js 22.19.0 or newer
- npm 11.10.0 or newer when developing or releasing from a checkout
- Pi (tested against Pi 0.84.1; older releases are untested)
- A native clipboard command (
pbcopy,wl-copy,xclip,xsel, orclip.exe) or a terminal that supports OSC 52
Core Pi packages remain wildcard peer dependencies so the package uses the Pi installation that loads it. The
latest-pi CI lane checks current Pi releases on an advisory basis.
Install
From npm:
pi install npm:@penumbral-labs/pi-copy-code
Then reload Pi:
/reload
For a one-off run without installing:
pi -e npm:@penumbral-labs/pi-copy-code
You can also load a checkout directly:
git clone https://github.com/penumbral-labs/pi-copy-code.git
cd pi-copy-code
npm ci
pi -e "$(pwd)"
Usage
Copy code from recent assistant messages:
/copy-code
The extension captures these shortcut names:
ctrl+alt+c
ctrl+super+c
alt+c
Pi calls the Meta/Command modifier super. Super-modified shortcuts require a terminal that reports modifiers
separately, such as one using the Kitty keyboard protocol. The alt+c registration handles terminals where a physical
Ctrl+Meta+C chord is remapped and arrives as Alt+C. The tradeoff is that a real Alt+C chord can also invoke the
extension; use /copy-code or another captured chord if that conflicts with your terminal workflow.
Copy quoted text (Markdown blockquotes) instead of code:
/copy-code quotes
The quote shortcuts mirror the code shortcuts with q in place of c:
ctrl+alt+q
ctrl+super+q
alt+q
Each quote is a run of consecutive > lines with one marker level (and its following space) removed; a blank line
starts a new quote. Quoted fences stay part of the quote text, and > lines inside fenced code are not quotes.
Edit before copying:
/copy-code edit
Arguments combine in any order, so /copy-code edit quotes edits a quote before copying it.
Edit mode opens $VISUAL, then $EDITOR, with the selected text in private temporary storage; set one of these
variables to your preferred editor command before using edit mode. On Windows, only .exe and .com targets spawn
directly. All other values, including extension-less names and .cmd/.bat shims, use the explicitly constructed,
escaped cmd.exe /d /s /c path.
When the picker opens:
↑/↓orj/k— move within the current response→ortab— move to an older response←orshift+tab— move toward the current responseenter— copy, or edit then copy when invoked with/copy-code edite— edit the selected block, then copyt— toggle between code blocks and quotes (shown only when both are available)/— fuzzy-search blocks in the current responsectrl+c,esc, orq— cancel
Response navigation wraps at both ends. The first picker item, All code blocks or All quotes, joins all blocks in
the selected response with blank lines.
Clipboard behavior
Native clipboard success is confirmed by the clipboard command and reported as Copied N lines via <command>. When no
native command is available and standard output is a TTY, the extension sends OSC 52 and reports
Sent N lines to terminal clipboard via OSC 52 (best effort). OSC 52 support and size limits vary by terminal, so this
fallback cannot confirm that the clipboard changed. Without either path, the extension reports that the terminal
clipboard is unavailable.
Fences nested under Markdown indentation are de-indented by the opening fence's structural whitespace while preserving additional code indentation. Indented Markdown code blocks without fences are not extracted.
Support and contributing
- Use the bug report form for reproducible problems.
- Use the feature request form for focused proposals.
- Read CONTRIBUTING.md before sending a pull request.
- Report vulnerabilities privately as described in SECURITY.md.
- See CHANGELOG.md for release history.
Package shape
Pi loads the TypeScript source extension directly. The npm tarball contains only package.json, the source extension,
README.md, CHANGELOG.md, and LICENSE; it has no runtime dependencies or install scripts.