Your company here — click to reach over 10,000 unique daily visitors

tty-copy - Man Page

copy content to the system clipboard via TTY


tty-copy [options] [<text...>]


tty-copy copies the given text to the controlling TTY using OSC 52 escape sequence and base64 encoding. If no text is given, tty-copy copies data from its standard input.

This allows terminals that support OSC 52 to copy the data into the system clipboard. It works in any terminal session, whether local, remote, or even nested therein! The supporting terminal must obviously (a) support OSC 52 and (b) have permission to access the clipboard.

The maximum length of an OSC 52 escape sequence is originally 100 000 bytes in total which means 74 994 bytes of plain text. However, some terminal emulators have higher limit; for example, kitty allows up to 8 MiB by default.

For the specification see the section Operating System Controls, code 52, Manipulate Selection Data, in Xterm Control Sequences (https://www.xfree86.org/current/ctlseqs.html).


-c,  --clear

Instead of copying anything, clear the clipboard so that nothing is copied.

-n,  --trim-newline

Do not copy the trailing newline character.

-o <file>, --output <file>

Path of the terminal device (defaults to /dev/tty).

-p,  --primary

Use the “primary” clipboard (selection) instead of the regular clipboard.

-T <type>, --term <type>

Specify the type of the terminal. Currently, only "screen" and "tmux" are recognized, any other value is interpreted as the default.

If not specified, "screen" and "tmux" are autodetected based on the TERM and TMUX environment variables.

-t,  --test

Test whether your terminal processes the OSC 52 escape sequence — if it does, exits with status code 0, otherwise with 1.

The fact that the terminal processes the sequence does not necessarily mean that access to the system clipboard will work — it may be disabled. This option only tests if the sequence is intercepted by the terminal or visibly printed on the screen.

-V,  --version

Display the version of tty-copy and exit.

-h,  --help

Display the help message and exit.

Exit Codes


Jakub Jirutka

Reporting Bugs

Report bugs to the project’s issue tracker at https://github.com/jirutka/tty-copy/issues.