theimpostor / osc

Access the system clipboard from anywhere using the ANSI OSC52 sequence
MIT License
56 stars 4 forks source link

Add support for reading clipboard #1

Closed theimpostor closed 1 year ago

theimpostor commented 2 years ago

Add support for reading the clipboard, which is supported by some terminals.

Spec is here: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Example with alacritty:

❯ printf "%s" "asdf" | base64
YXNkZg==

# write 'asdf' to the clipboard
❯ printf "\033]52;c;$(printf "%s" "asdf" | base64)\a"

# query the clipboard, get base64-encoded 'asdf' written to terminal
❯ printf "\033]52;c;?"
^[]52;c;YXNkZg==^[\
❯ YXNkZg==
theimpostor commented 2 years ago

See also: https://github.com/rumpelsepp/oscclip

theimpostor commented 1 year ago

Basic paste support has been added.