File: README.md

package info (click to toggle)
yank 1.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 104 kB
  • sloc: ansic: 415; makefile: 62
file content (165 lines) | stat: -rw-r--r-- 3,045 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# yank

Yank terminal output to clipboard.

![yank](https://raw.githubusercontent.com/mptre/yank/gh-pages/screencast.gif)

## Description

The
[yank(1)][yank]
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)][xsel]
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:

  ```sh
  $ env | yank -d =
  ```

- Yank a field from a CSV file:

  ```sh
  $ yank -d \", <file.csv
  ```

- Yank a whole line using the `-l` option:

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

  ```sh
  $ ps ux | yank -g [0-9]+ | xargs kill
  ```

- Yank the selected field to the clipboard as opposed of the default primary
  clipboard:

  ```sh
  $ yank -- xsel -b
  ```

## Installation

### Arch Linux

On AUR:

```sh
$ yaourt -S yank
```

### Debian

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

```sh
$ 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

```sh
$ nix-env -i yank
```

### openSUSE

```
$ zypper install yank
```

### macOS via Homebrew

```sh
$ brew install yank
```

### macOS via MacPorts

```sh
$ sudo port install yank
```

### FreeBSD

```sh
$ pkg install yank
```

### OpenBSD

```sh
$ pkg_add yank
```

### From source

The install directory defaults to `/usr/local`:

```sh
$ make install
```

Change the install directory using the `PREFIX` variable:

```sh
$ make PREFIX=DIR install
```

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

```sh
$ make YANKCMD=pbcopy
```

## License

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

[xsel]: http://www.vergenet.net/~conrad/software/xsel/
[yank]: https://www.basename.se/yank/