omp packages

pi-lot-pack-copy-shortcut0.1.1

Copies the last assistant message to the clipboard with a shortcut of your choice.

zephinel Published 2 days ago Apache-2.0 ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

copy-shortcut

Copies the last assistant message to the clipboard with a shortcut (ctrl+alt+y by default). /copy-shortcut changes the shortcut and checks it for conflicts.

copy-shortcut is a separate extension of Pi-lot Pack, not part of the permission extension. It only registers the shortcut and copies; turning it off, or a failure in it, changes no decision of the permission extension.

Install

pi install npm:pi-lot-pack-copy-shortcut

Or every extension of Pi-lot Pack at once with pi install npm:pi-lot-pack. Install one or the other: with both, this extension loads twice.

What it copies

  • Text first: like Pi's own /copy, it copies the text blocks of the last assistant message on the current branch (aborted messages with no content are skipped).
  • Without text: when the last assistant message has only thinking or tool calls, it copies thinking and [Tool: <name> <json-args>] instead.
  • Commands:
    • /copy-shortcut (with a UI): opens an input in the shared terminal view (extensions/shared/screen.ts) that names the current shortcut. After you type and save a new one, /reload puts it in use.
    • /copy-shortcut (without a UI): says the shortcut in use.
    • /copy-shortcut <shortcut> (such as /copy-shortcut ctrl+shift+k): checks and saves it directly, with no input.

Settings file

The file:

~/.pi/agent/pi-lot-pack/copy-shortcut.json

When the file is not there at the first load, and is not a dangling symbolic link, the defaults are written. When it is a symbolic link (into a folder you sync, for example), a change of the shortcut updates the target and keeps the link.

The defaults:

{
  "shortcut": "ctrl+alt+y",
  "successMessage": "Copied the last agent message to the clipboard.",
  "emptyMessage": "No agent messages to copy yet."
}
  • When the file has a shortcut that is not supported, the start says "The saved copy shortcut is not supported. Using ctrl+alt+y instead." and ctrl+alt+y is used.
  • When neither a clipboard program nor the terminal's own clipboard (OSC 52) can copy, the notice is always "The last agent message was not copied to the clipboard.": no cause is guessed, and no command or system error is shown.

Supported shortcuts

  • Form: one or more modifiers (ctrl, alt, shift, super; the aliases control, option, cmd, command work, and the order is made ctrl+alt+shift+super+<key>) and one key.
  • Character keys: letters, digits and ASCII punctuation (such as ctrl+alt+y).
  • Special keys: enter, return, space, tab, backspace, delete, insert, clear (only ctrl+clear or shift+clear), up, down, left, right, home, end, pageup, pagedown.
  • Refused:
    • Function keys (f1–f12), meta, and escape with modifiers.
    • A shortcut that Pi keeps for itself (PI_RESERVED, such as app.interrupt, app.clear, tui.select.confirm): the notice says it is already one of Pi's keys and nothing changed. Otherwise Pi would skip it at load without a word.

Clipboard programs and remote sessions

Where Tried in this order
macOS pbcopy
Windows clip
Linux / Android termux-clipboard-set (Termux) → wl-copy (Wayland) → xclip -selection clipboard → xsel --clipboard --input
A remote session (SSH_CONNECTION / SSH_CLIENT / MOSH_CONNECTION), or when the local programs fail The OSC 52 terminal clipboard sequence, in addition or instead (at most 100,000 bytes encoded)

One copy may take 5,000 ms in all, and each program gets what is left of it. A new copy, or the end of the session (session_shutdown), stops the copy before it at once.

Development and tests

From the repository root:

node --no-warnings --test extensions/copy-shortcut/test/*.test.mjs test/copy-shortcut-key-contract.test.mjs
npm run check