-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathyank.1
154 lines (154 loc) · 3.02 KB
/
yank.1
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
.Dd $Mdocdate: July 10 2015 $
.Dt YANK 1
.Os
.Sh NAME
.Nm yank
.Nd yank terminal output to clipboard
.Sh SYNOPSIS
.Nm
.Op Fl 1ilxv
.Op Fl d Ar delim
.Op Fl g Ar pattern
.Op Fl - Ar command Op Ar argument ...
.Sh DESCRIPTION
Read input from
.Pa 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
.Fl g
option or by splitting the input on a delimiter sequence using the
.Fl d
option, see
.Sx DELIMITERS .
.Pp
Using the arrow keys will move the selected field, see
.Sx COMMANDS .
Pressing the return key will invoke
.Ar command
and write the selected field to its
.Pa stdin .
The
.Ar command
defaults to
.Xr xsel 1x
but could be anything that accepts input on
.Pa stdin ,
see
.Sx EXAMPLES .
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 1
If only one field is recognized, select it and invoke
.Ar command
without displaying the selection interface.
.It Fl d Ar delim
All input characters not present in
.Ar delim
will be recognized as fields, see
.Sx DELIMITERS .
.It Fl g Ar pattern
Use
.Ar pattern
to recognize fields, expressed as a POSIX extended regular expression.
.It Fl i
Ignore case differences between
.Ar pattern
and the input.
.It Fl l
Use the default delimiters except for space, see
.Sx DELIMITERS .
.It Fl v
Prints version.
.It Fl x
Use alternate screen.
.It Fl - Ar command Op Ar argument ...
Use
.Ar command
with zero or more
.Ar args
as the yank command.
.El
.Sh COMMANDS
.Bl -tag -width XXXX
.It Ic Ctrl-A | g
Move selection to the first field.
.It Ic Ctrl-C | Ctrl-D
Exit without invoking the yank command.
.It Ic Ctrl-E | G
Move selection to the last field.
.It Ic Ctrl-P Ns / Ns Ic Ctrl-N | Ic Left Ns / Ns Ic Right | Ic h Ns / Ns Ic l
Move selection to the left or right.
.It Ic Up Ns / Ns Ic Down | Ic j Ns / Ns Ic k
Move selection to the next or previous line.
.It Ic Enter
Exit using the selected field.
.El
.Sh DELIMITERS
If the
.Fl d
and
.Fl g
options are omitted the following characters are recognized as delimiters by
default:
.Bl -tag -width XXXX
.It \ef
form feed
.It \en
new line
.It \er
carriage return
.It \es
space
.It \et
horizontal tab
.El
.Pp
If the
.Fl d
option is present space is not recognized as a delimiter.
.Sh EXAMPLES
Yank an environment variable key or value:
.Pp
.Dl $ env | yank -d =
.Pp
Yank a field from a CSV file:
.Pp
.Dl $ yank -d \e\&", <file.csv
.Pp
Yank a whole line using the
.Fl l
option:
.Pp
.Dl $ make 2>&1 | yank -l
.Pp
If
.Pa stdout
is not a terminal the selected field will be written to
.Pa stdout
and exit without invoking the yank command.
Kill the selected PID:
.Pp
.Dl $ ps ux | yank -g [0-9]+ | xargs kill
.Pp
Yank the selected field to the clipboard as opposed of the default primary
clipboard:
.Pp
.Dl $ yank \(em xsel -b
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
.Xr re_format 7
.Sh AUTHORS
.An Anton Lindqvist Aq Mt [email protected]
.Sh CAVEATS
Recognizing fields enclosed in brackets requires
.Sq \&]
to be present before
.Sq \&[
in the argument given to the
.Fl d
option,
see
.Xr re_format 7 .