Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

About

A copy mark under every code block in a Claude Code reply: click it, the block is on your clipboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

copy-blocks

A copy mark under every code block in a Claude Code reply. When Claude gives you a command to run, click the mark and the block is on your clipboard, as written. The mark reads ✓ copied! for two seconds.

echo "a block Claude gave you"
                                                    ⧉ ctrl+click
  • Fullscreen layout (/tui fullscreen): the mark is ⧉ copy, a button. A plain click copies.
  • The ordinary layout: the terminal, not Claude Code, gets the click there, so the mark is ⧉ ctrl+click, a link your terminal opens on Ctrl+click. It points at a small file holding the block, and a desktop handler copies the file's text. Run /clip setup once to put the handler in place. Until then the mark reads ⧉ /clip a3f9, its code.
  • Anywhere: /clip copies the newest block, /clip 2 the one before it, and /clip a3f9 the block whose mark shows that code. That's the way in tmux, whose mouse mode takes the click before the terminal can open a link.

Install

At the prompt of a Claude Code session:

/plugin install copy-blocks --marketplace code-wheel/copy-blocks

Answer y to add the marketplace, then pick a scope. From a shell:

claude plugin install copy-blocks --marketplace code-wheel/copy-blocks

Then, for the ordinary layout, run /clip setup in a session. /clip setup remove takes the handler out.

What it needs

  • Linux with X11 and xclip (sudo apt install xclip). It copies with xclip -selection clipboard.
  • For Ctrl+click in the ordinary layout: a terminal that opens links (GNOME Terminal, and most VTE terminals, do) and a desktop that follows xdg-mime. /clip setup installs, for your user only: ~/.local/bin/copy-block, a MIME type for *.copyblock files, and a hidden copy-block.desktop that opens them.
  • Not yet: macOS (pbcopy), Wayland without XWayland (wl-copy), Windows.

How it works

  • A ui.render hook on Claude Code's CodeBlock keeps each closed block as it is drawn and adds the mark under it.
  • Fullscreen: the mark is a Button, and its press runs xclip with the block on its input.
  • Ordinary layout: the block is written to ~/.cache/copy-blocks/<hash>.copyblock, and the mark is a link to that file. Opening it runs copy-block, which copies the text and writes the file's name to ~/.cache/copy-blocks/last-click. The mod looks at that file twice a second to turn the clicked block's mark into ✓ copied!. Block files older than a week are removed when a session starts.

Develop

claude plugin validate .
claude plugin test .
claude --plugin-dir .

Releases go through a release lane (release.json): the version is the one in .claude-plugin/plugin.json, and each release is a v<version> tag on main, which is what an install or an update reads.

License

MIT

About

A copy mark under every code block in a Claude Code reply: click it, the block is on your clipboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages