yank

Yank terminal output to clipboard

Github星跟蹤圖

yank

Yank terminal output to clipboard.

yank

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:

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

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

    $ 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:

    $ 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
    

Installation

Arch Linux

On AUR:

$ yaourt -S yank

Debian

On testing and unstable:

$ 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:

$ 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

$ nix-env -i yank

openSUSE

$ zypper install yank

macOS

$ brew install yank

FreeBSD

$ pkg install yank

OpenBSD

$ pkg_add yank

From source

The install directory defaults to /usr/local:

$ make install

Change the install directory using the PREFIX variable:

$ make PREFIX=DIR install

The default yank command can be defined using the YANKCMD variable.
For instance,
macOS users would prefer pbcopy(1):

$ make YANKCMD=pbcopy

License

Copyright (c) 2019 Anton Lindqvist.
Distributed under the MIT license.

主要指標

概覽
名稱與所有者mptre/yank
主編程語言C
編程語言Makefile (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2015-08-24 15:23:17
推送於2022-10-03 00:06:42
最后一次提交2022-10-02 21:15:11
發布數23
最新版本名稱v1.3.0 (發布於 )
第一版名稱v0.1.0 (發布於 )
用户参与
星數1.7k
關注者數22
派生數48
提交數193
已啟用問題?
問題數36
打開的問題數2
拉請求數11
打開的拉請求數0
關閉的拉請求數24
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?