clip

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package clip writes text to the system clipboard.

Two strategies, tried in this order unless overridden by PE_CLIP:

  1. A native helper, if one is on PATH: macOS pbcopy Linux/Wayland wl-copy Linux/X11 xclip / xsel WSL clip.exe (after the above fail) Windows clip

  2. OSC 52 escape sequence written to /dev/tty. Carries the clipboard payload through the terminal emulator (and through tmux/SSH on the way), so it works on a headless remote box as long as the local terminal — WezTerm, iTerm2, kitty, Alacritty, modern xterm, Windows Terminal, etc. — opts into OSC 52.

PE_CLIP overrides the strategy:

PE_CLIP=native  use a native helper, fail if absent
PE_CLIP=osc52   skip native, always emit OSC 52
PE_CLIP=none    no-op (useful for testing pe itself)
(unset)         auto: native first, OSC 52 fallback

Index

Constants

This section is empty.

Variables

View Source
var ErrNoBackend = errors.New("no clipboard backend found")

ErrNoBackend is returned when no supported clipboard backend can be used.

Functions

func Copy

func Copy(s string) error

Copy writes s to the system clipboard, honoring PE_CLIP.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL