.Dd $Mdocdate: July 10 2015 $ .Dt YANK 1 .Os .Sh NAME .Nm yank .Nd yank terminal output to clipboard .Sh SYNOPSIS .Nm .Op Fl ilxv .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 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\&", &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 -- xsel -b .Sh DIAGNOSTICS .Ex -std .Sh SEE ALSO .Xr re_format 7 .Sh AUTHORS .An Anton Lindqvist Aq Mt anton@basename.se .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 .