YANK(1)

okay bestie, welcome to YANK(1) from the General Commands Manual โ€” the page for yank, aka the command that yanks terminal output to your clipboard. ๐Ÿ’–โœจ

๐ŸŒธ NAME ๐ŸŒธ

yank โ€” yank terminal output to clipboard. That's literally the whole vibe. ๐Ÿ’…

โœจ SYNOPSIS โœจ

yank [-1ilxv] [-d delim] [-g pattern] [-- command [argument ...]]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Okay so here's the tea: yank reads input from stdin and shows you a selection interface where a field can be selected and copied to the clipboard. Fields are recognized either by a regular expression using the -g option, or by splitting the input on a delimiter sequence using the -d option โ€” see โ€œDELIMITERSโ€ for the deets. ๐ŸŽ€

Using the arrow keys will move the selected field โ€” see โ€œCOMMANDSโ€ for the full menu. Pressing the return key will invoke command and write the selected field to its stdin. The command defaults to xsel, but bestie it could be anything that accepts input on stdin โ€” see โ€œEXAMPLESโ€. ๐Ÿซถ

The options are as follows:

๐Ÿ’… OPTIONS ๐Ÿ’…

  • -1 โ€” If only one field is recognized, select it and invoke command without displaying the selection interface.
  • -d delim โ€” All input characters not present in delim will be recognized as fields, see โ€œDELIMITERSโ€.
  • -g pattern โ€” Use pattern to recognize fields, expressed as a POSIX extended regular expression.
  • -i โ€” Ignore case differences between pattern and the input.
  • -l โ€” Use the default delimiters except for space, see โ€œDELIMITERSโ€.
  • -v โ€” Prints version.
  • -x โ€” Use alternate screen.
  • -- command [argument ...] โ€” Use command with zero or more args as the yank command.

๐ŸŽฎ COMMANDS ๐ŸŽฎ

  • Ctrl-A | g โ€” Move selection to the first field.
  • Ctrl-C | Ctrl-D โ€” Exit without invoking the yank command.
  • Ctrl-E | G โ€” Move selection to the last field.
  • Ctrl-P/Ctrl-N | Left/Right | h/l โ€” Move selection to the left or right.
  • Ctrl-L โ€” Toggle between current and line delimiter, equivalent to the -l option.
  • Up/Down | j/k โ€” Move selection to the next or previous line.
  • Enter โ€” Exit using the selected field.

๐ŸŽ€ DELIMITERS ๐ŸŽ€

If the -d and -g options are omitted the following characters are recognized as delimiters by default:

  • \f โ€” form feed
  • \n โ€” new line
  • \r โ€” carriage return
  • \s โ€” space
  • \t โ€” horizontal tab
Heads up bestie: if the -d option is present, space is not recognized as a delimiter. ๐Ÿ’…

๐ŸŒˆ EXAMPLES ๐ŸŒˆ

Yank an environment variable key or value:

$ env | yank -d =

Yank a field from a CSV file:

$ yank -d \", <file.csv

Yank a whole line using the -l option:

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

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

Yank the selected field to the clipboard instead of the default primary clipboard:

$ yank โ€” xsel -b

๐Ÿ’€ DIAGNOSTICS ๐Ÿ’€

The yank utility exits 0 on success, and >0 if an error occurs. Periodt.

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

re_format(7)

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Anton Lindqvist <anton@basename.se>

๐Ÿ™ˆ CAVEATS ๐Ÿ™ˆ

Recognizing fields enclosed in brackets requires ] to be present before [ in the argument given to the -d option, see re_format(7).


okay bye bestie โ€” this page is from Debian, dated July 10, 2015. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from