Yank terminal output to clipboard.
Read input from stdin and display a selection interface that allows a field to
be selected and copied to the clipboard.
Fields are either recognized by a regular expression using the -g option or by
splitting the input on a delimiter sequence using the -d option.
Using the arrow keys will move the selected field.
The interface supports several Emacs and Vi like key bindings,
consult the man page for further reference.
Pressing the return key will invoke the yank command and write the selected
field to its stdin.
The yank command defaults to xsel(1) but could be anything that accepts input
on stdin.
When invoking yank,
everything supplied after the -- option will be used as the yank command,
see examples below.
Others including myself consider it a cache miss when resort to using the mouse. Copying output from the terminal is still one of the few cases where I still use the mouse. Several terminal multiplexers solves this issue, however I don't want to be required to use a multiplexer but instead use a terminal agnostic solution.
-
Yank an environment variable key or value:
env | yank -d = -
Yank a field from a CSV file:
yank -d \", <file.csv
-
Yank a whole line using the
-loption:make 2>&1 | yank -l
-
If
stdoutis not a terminal the selected field will be written tostdoutand exit without invoking the yank command. Kill the selected PID:ps ux | yank -g [0-9]+ | xargs kill
-
Yank the selected field to the clipboard as opposed of the default primary clipboard:
yank -- xsel -b
On AUR:
yaourt -S yankOn testing and unstable:
sudo apt-get install yankThe binary is installed at /usr/bin/yank-cli due to a naming conflict.
Versions 24/25/26/Rawhide:
sudo dnf install yankThe binary is installed at /usr/bin/yank-cli due to a naming conflict.
Man-pages are available as both yank and yank-cli.
nix-env -i yankbrew install yankpkg_add yankThe install directory defaults to /usr/local:
make installChange the install directory using the PREFIX variable:
make PREFIX=DIR installThe default yank command can be defined using the YANKCMD variable.
For instance,
macOS users would prefer pbcopy(1):
make YANKCMD=pbcopyCopyright (c) Anton Lindqvist. Distributed under the MIT license.
