1.Dd $Mdocdate: July 10 2015 $ 2.Dt YANK 1 3.Os 4.Sh NAME 5.Nm yank 6.Nd yank terminal output to clipboard 7.Sh SYNOPSIS 8.Nm 9.Op Fl ilxv 10.Op Fl d Ar delim 11.Op Fl g Ar pattern 12.Op Fl - Ar command Op Ar argument ... 13.Sh DESCRIPTION 14Read input from 15.Pa stdin 16and display a selection interface that allows a field to be selected and copied 17to the clipboard. 18Fields are either recognized by a regular expression using the 19.Fl g 20option or by splitting the input on a delimiter sequence using the 21.Fl d 22option, see 23.Sx DELIMITERS . 24.Pp 25Using the arrow keys will move the selected field, see 26.Sx COMMANDS . 27Pressing the return key will invoke 28.Ar command 29and write the selected field to its 30.Pa stdin . 31The 32.Ar command 33defaults to 34.Xr xsel 1x 35but could be anything that accepts input on 36.Pa stdin , 37see 38.Sx EXAMPLES . 39.Pp 40The options are as follows: 41.Bl -tag -width Ds 42.It Fl d Ar delim 43All input characters not present in 44.Ar delim 45will be recognized as fields, see 46.Sx DELIMITERS . 47.It Fl g Ar pattern 48Use 49.Ar pattern 50to recognize fields, expressed as a POSIX extended regular expression. 51.It Fl i 52Ignore case differences between 53.Ar pattern 54and the input. 55.It Fl l 56Use the default delimiters except for space, see 57.Sx DELIMITERS . 58.It Fl v 59Prints version. 60.It Fl x 61Use alternate screen. 62.It Fl - Ar command Op Ar argument ... 63Use 64.Ar command 65with zero or more 66.Ar args 67as the yank command. 68.El 69.Sh COMMANDS 70.Bl -tag -width XXXX 71.It Ic Ctrl-A | g 72Move selection to the first field. 73.It Ic Ctrl-C | Ctrl-D 74Exit without invoking the yank command. 75.It Ic Ctrl-E | G 76Move selection to the last field. 77.It Ic Ctrl-P Ns / Ns Ic Ctrl-N | Ic Left Ns / Ns Ic Right | Ic h Ns / Ns Ic l 78Move selection to the left or right. 79.It Ic Up Ns / Ns Ic Down | Ic j Ns / Ns Ic k 80Move selection to the next or previous line. 81.It Ic Enter 82Exit using the selected field. 83.El 84.Sh DELIMITERS 85If the 86.Fl d 87and 88.Fl g 89options are omitted the following characters are recognized as delimiters by 90default: 91.Bl -tag -width XXXX 92.It \ef 93form feed 94.It \en 95new line 96.It \er 97carriage return 98.It \es 99space 100.It \et 101horizontal tab 102.El 103.Pp 104If the 105.Fl d 106option is present space is not recognized as a delimiter. 107.Sh EXAMPLES 108Yank an environment variable key or value: 109.Pp 110.Dl $ env | yank -d = 111.Pp 112Yank a field from a CSV file: 113.Pp 114.Dl $ yank -d \e\&", <file.csv 115.Pp 116Yank a whole line using the 117.Fl l 118option: 119.Pp 120.Dl $ make 2>&1 | yank -l 121.Pp 122If 123.Pa stdout 124is not a terminal the selected field will be written to 125.Pa stdout 126and exit without invoking the yank command. 127Kill the selected PID: 128.Pp 129.Dl $ ps ux | yank -g [0-9]+ | xargs kill 130.Pp 131Yank the selected field to the clipboard as opposed of the default primary 132clipboard: 133.Pp 134.Dl $ yank -- xsel -b 135.Sh DIAGNOSTICS 136.Ex -std 137.Sh SEE ALSO 138.Xr re_format 7 139.Sh AUTHORS 140.An Anton Lindqvist Aq Mt anton@basename.se 141.Sh CAVEATS 142Recognizing fields enclosed in brackets requires 143.Sq \&] 144to be present before 145.Sq \&[ 146in the argument given to the 147.Fl d 148option, 149see 150.Xr re_format 7 . 151