• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

CHANGELOG.mdH A D12-Aug-20195 KiB215133

LICENSEH A D12-Aug-20191.1 KiB2217

MakefileH A D12-Aug-20191,007 5641

README.mdH A D12-Aug-20192.9 KiB162111

yank.1H A D12-Aug-20192.9 KiB151150

yank.cH A D12-Aug-20199 KiB478405

README.md

1# yank
2
3Yank terminal output to clipboard.
4
5![yank](https://raw.githubusercontent.com/mptre/yank/gh-pages/screencast.gif)
6
7## Description
8
9The
10[yank(1)][yank]
11utility reads input from `stdin` and display a selection interface that allows a
12field to be selected and copied to the clipboard.
13Fields are either recognized by a regular expression using the `-g` option or by
14splitting the input on a delimiter sequence using the `-d` option.
15
16Using the arrow keys will move the selected field.
17The interface supports several Emacs and Vi like key bindings,
18consult the man page for further reference.
19Pressing the return key will invoke the yank command and write the selected
20field to its `stdin`.
21The yank command defaults to
22[xsel(1)][xsel]
23but could be anything that accepts input on `stdin`.
24When invoking yank,
25everything supplied after the `--` option will be used as the yank command,
26see examples below.
27
28## Motivation
29
30Others including myself consider it a cache miss when resort to using the mouse.
31Copying output from the terminal is still one of the few cases where I still use
32the mouse.
33Several terminal multiplexers solves this issue,
34however I don't want to be required to use a multiplexer but instead use a
35terminal agnostic solution.
36
37## Examples
38
39- Yank an environment variable key or value:
40
41  ```sh
42  $ env | yank -d =
43  ```
44
45- Yank a field from a CSV file:
46
47  ```sh
48  $ yank -d \", <file.csv
49  ```
50
51- Yank a whole line using the `-l` option:
52
53  ```sh
54  $ make 2>&1 | yank -l
55  ```
56
57- If `stdout` is not a terminal the selected field will be written to `stdout`
58  and exit without invoking the yank command.
59  Kill the selected PID:
60
61  ```sh
62  $ ps ux | yank -g [0-9]+ | xargs kill
63  ```
64
65- Yank the selected field to the clipboard as opposed of the default primary
66  clipboard:
67
68  ```sh
69  $ yank -- xsel -b
70  ```
71
72## Installation
73
74### Arch Linux
75
76On AUR:
77
78```sh
79$ yaourt -S yank
80```
81
82### Debian
83
84On testing and unstable:
85
86```sh
87$ sudo apt-get install yank
88```
89
90The binary is installed at `/usr/bin/yank-cli` due to a naming conflict.
91
92### Fedora
93
94Versions 24/25/26/Rawhide:
95
96```sh
97$ sudo dnf install yank
98```
99
100The binary is installed at `/usr/bin/yank-cli` due to a naming conflict.
101Man-pages are available as both `yank` and `yank-cli`.
102
103### Nix/NixOS
104
105```sh
106$ nix-env -i yank
107```
108
109### openSUSE
110
111```
112$ zypper install yank
113```
114
115### macOS
116
117```sh
118$ brew install yank
119```
120
121### FreeBSD
122
123```sh
124$ pkg install yank
125```
126
127### OpenBSD
128
129```sh
130$ pkg_add yank
131```
132
133### From source
134
135The install directory defaults to `/usr/local`:
136
137```sh
138$ make install
139```
140
141Change the install directory using the `PREFIX` variable:
142
143```sh
144$ make PREFIX=DIR install
145```
146
147The default yank command can be defined using the `YANKCMD` variable.
148For instance,
149macOS users would prefer `pbcopy(1)`:
150
151```sh
152$ make YANKCMD=pbcopy
153```
154
155## License
156
157Copyright (c) 2018 Anton Lindqvist.
158Distributed under the MIT license.
159
160[xsel]: http://www.vergenet.net/~conrad/software/xsel/
161[yank]: https://www.basename.se/yank/
162