Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
Y

yank

> 编程语言
Open source

Yank terminal output to clipboard

1.7K stars0 likes0 views
WebsiteGitHub

About

Yank terminal output to clipboard

yank

Yank terminal output to clipboard.

Description

The yank(1) utility reads 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.

Motivation

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.

Examples

  • Yank an environment variable key or value:

    bash
    $ env | yank -d =
  • Yank a field from a CSV file:

    bash
    $ yank -d \", <file.csv
  • Yank a whole line using the -l option:

    bash
    $ make 2>&1 | yank -l
  • If stdout is not a terminal the selected field will be written to stdout and exit without invoking the yank command. Kill the selected PID:

    bash
    $ ps ux | yank -g [0-9]+ | xargs kill
  • Yank the selected field to the clipboard as opposed of the default primary clipboard:

    bash
    $ yank -- xsel -b

Installation

Arch Linux

bash
$ pacman -S yank

Debian

bash
$ sudo apt-get install yank

The binary is installed at /usr/bin/yank-cli due to a naming conflict.

Fedora

Versions 24/25/26/Rawhide:

bash
$ sudo dnf install yank

The binary is installed at /usr/bin/yank-cli due to a naming conflict. Man-pages are available as both yank and yank-cli.

Nix/NixOS

bash
$ nix-env -i yank

openSUSE

$ zypper install yank

macOS via Homebrew

bash
$ brew install yank

macOS via MacPorts

bash
$ sudo port install yank

FreeBSD

bash
$ pkg install yank

OpenBSD

bash
$ pkg_add yank

From source

The install directory defaults to /usr/local:

bash
$ make install

Change the install directory using the PREFIX variable:

bash
$ make PREFIX=DIR install

The default yank command can be defined using the YANKCMD variable.

  • macOS users would prefer pbcopy(1):

    bash
    $ make YANKCMD=pbcopy
  • Using shcopy(1) allows the selected field to be synchronized with the clipboard on your local machine when using yank over SSH or in headless environments.

    bash
    $ make YANKCMD=shcopy

License

Copyright (c) 2015-2026 Anton Lindqvist. Distributed under the MIT license.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言