blib/lib/App/nup.pm

filter: Statementstmt 100% 2 / 2 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 100% 2 / 2 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/App/optex/up.pm ↑ Summary
1 package App::nup;
2  
3 1 our $VERSION = "1.27";
4  
5 1 1;
6 =encoding utf-8
7  
8 =head1 NAME
9  
10 nup - n-up, multi-column paged output for commands and files
11  
12 =head1 SYNOPSIS
13  
14 nup [ options ] file ...
15 nup -e [ options ] command ...
16  
17 -h --help show help
18 --version show version
19 -d --debug debug mode
20 -n --dryrun dry-run mode
21 -e --exec execute command mode
22 --alias=CMD=OPTS set command alias
23 -V --parallel parallel view mode
24 -D --document document mode (default: on)
25 -F --no-paginate disable page mode
26 -A --auto-paginate auto disable page mode for single column
27 -L --lateral pages or files in one row, scrolled sideways
28 -H --filename show filename headers (default: on)
29 -C --pane=#[,#] number of columns, and rows (e.g., 2,2)
30 -P --page=# page height in lines
31 -S --pane-width=# pane width (default: 85)
32 -w --width=# output width
33 --ac --column-opts options for ansicolumn
34 --bs --border-style=# border style (default: heavy-box)
35 --ls --line-style=# line style (none/truncate/wrap/wordwrap)
36 --runin=# run-in width for line breaking
37 --runout=# run-out width for line breaking
38 --runlen=# set both run-in and run-out
39 --boundary=# fold boundary: word, space or none
40 --cm --colormap=# color mapping (LABEL=COLOR)
41 --[no-]page-number page number on border (default: on)
42 --textconv[=EXT] textconv for non-text files
43 --hi --highlight[=#] syntax highlight of files (default: on)
44 --no-highlight disable syntax highlight (--no-hi)
45 --pager=# pager command (empty to disable)
46 --no-pager disable pager
47 -T --device=# output device: tty, pdf, or a paper for PDF
48 (e.g., a4, a4p, a3l)
49 -o --output=FILE output file (PDF when it ends with .pdf)
50 --pdf-opts=# options for ansi2pdf (e.g., "-l 80")
51 --geometry print the size and the kind of the device
52 --white-board black on white board
53 --black-board white on black board
54 --green-board white on green board
55 --slate-board white on dark slate board
56  
57 =head1 VERSION
58  
59 Version 1.27
60  
61 =cut
62 =head1 DESCRIPTION
63  
64 B<N-up> (command: C<nup>) is a multi-column paged output tool.
65 It provides a convenient way to view files or run commands in
66 n-up layout using the L<App::optex::up> module through C<optex>.
67  
68 =begin html
69  
70 <p><img width="750" src="https://raw.githubusercontent.com/tecolicom/App-nup/main/images/nup.png"></p>
71  
72 =end html
73  
74 C<nup> automatically detects the mode based on the first argument:
75 if it is an existing file, n-up file view mode is used; if it is an
76 executable command, n-up command mode is used. Use C<-e> option to
77 force command mode when needed.
78  
79 In file view mode, C<nup> stops parsing its own options at the first
80 file name and hands the file names and everything after them to
81 L<ansicolumn> unchanged. Options of C<ansicolumn> that C<nup> does
82 not provide can therefore be given after the file names:
83  
84 nup -C2 file1.txt file2.txt --tabstop 4
85  
86 They can be given by C<--column-opts> as well, which works in command
87 mode too:
88  
89 nup -C2 --column-opts --tabstop 4 -- file1.txt file2.txt
90  
91 =head1 OPTIONS
92  
93 =head2 General Options
94  
95 =over 4
96  
97 =item B<-h>, B<--help>
98  
99 Show help message.
100  
101 =item B<--version>
102  
103 Show version.
104  
105 =item B<-d>, B<--debug>
106  
107 Enable debug mode.
108  
109 =item B<-n>, B<--dryrun>
110  
111 Dry-run mode. Show the command without executing.
112  
113 =item B<-e>, B<--exec>
114  
115 Force command execution mode. Normally the mode is auto-detected,
116 but use this option when you want to execute a file as a command.
117  
118 =item B<--alias>=I<NAME>=I<CMD> I<OPTS>...
119  
120 Define command alias. When a command matches I<NAME>, it is replaced
121 by I<CMD> with specified I<OPTS>. This can be used to add default
122 options or to substitute a different command.
123 Multiple C<--alias> options can be specified.
124  
125 Default aliases:
126  
127 bat bat --style=plain --color=always
128 batcat batcat --style=plain --color=always
129 mdcat mdcat --ansi
130 rg rg --color=always
131 tree tree -C
132  
133 Example:
134  
135 nup --alias='grep=ggrep --color=always' grep pattern file
136  
137 =item B<-V>, B<--parallel>
138  
139 Enable parallel view mode for ansicolumn. In this mode, each file
140 is displayed in its own column without pagination, similar to
141 C<--no-paginate>. Automatically enabled when multiple files are
142 specified. Single file or stdin input results in single column
143 output.
144  
145 =item B<-D>, B<--document>
146  
147 Enable document mode for ansicolumn. This mode is optimized for
148 viewing documents with n-up page-based layout. Enabled by default.
149 Use C<--no-document> to disable.
150  
151 =for comment
152 --fold is accepted as an undocumented alias for backward compatibility
153  
154 =item B<-F>, B<--no-paginate>
155  
156 Disable page mode. Without pagination, the entire content is
157 split evenly across columns. Page mode is the default; use
158 B<--paginate> to re-enable if needed.
159  
160 =item B<-A>, B<--auto-paginate>
161  
162 Automatically disable page mode when only one column fits the
163 terminal. This is useful when using C<nup> as C<MANPAGER>,
164 where single-column page splitting wastes space.
165  
166 =item B<-L>, B<--lateral>
167  
168 Put all the pages in one row, however wide it becomes, instead of
169 filling the screen with as many panes as fit and going on below.
170 The row is as high as the screen, and it is seen by scrolling
171 sideways in the pager.
172  
173 The screen shows the same number of panes as without this option:
174 as many as fit, or the number given by C<-C>. With C<-C4>, four
175 pages are on the screen at a time, each a quarter of it wide.
176  
177 The page number has a triangle on each side, as C<◂ 2/12 ▸>, which
178 tells that the row can be scrolled in that direction: the triangle is
179 filled when there is a page there, and open at the end of the row
180 (C<◃ 1/12 ▸>). They are the C<%L> and C<%R> of the C<--label> option
181 of C<ansicolumn>; give other marks by C<--mark>, after the file names
182 (C<--mark RIGHT=E<gt>E<gt> --mark RIGHT_END=>).
183  
184 When the pager is C<less>, C<nup> adds
185 C<< -S --shift=I<N> --rscroll=- >> to it, where I<N> is the width of
186 a pane: the lines are not wrapped, and the right and left arrow keys
187 move by one page.
188  
189 C<nup> also puts the following keys in the C<LESSKEY_CONTENT>
190 environment variable, which C<less> 661 or later reads. With three panes on the
191 screen and a C<less> older than 710, they are:
192  
193 h , left left-scroll one page to the left
194 l . right right-scroll one page to the right
195 H g < K no-scroll the left end of the row
196 L G > J end-scroll the right end of the row
197 space f j noaction ESC-) x 3 the panes on the screen to the right
198 down d ^D return
199 b k up u ^U noaction ESC-( x 3 the panes on the screen to the left
200  
201 The pages have the height of the screen, and there is nothing to
202 scroll down to: C<j> and C<k>, the down and up arrows, C<d> and C<u>,
203 C<^D> and C<^U>, and the return key go on to the
204 next and the previous screen, as space and C<b> do.
205 C<noaction> does nothing and then types the keys after it, here
206 ESC-) three times. It cannot type the arrow keys, so ESC-) and
207 ESC-( are given the same actions as the right and left arrow. In
208 C<LESSKEY_CONTENT>, they are in one line, joined by C<;>, as
209 C<h left-scroll;l right-scroll;...>, and space is written C<\ >, a
210 backslash and a space.
211 With C<less> 710 or later, C<l>, C<.>, the right arrow and ESC-) are
212 C<right-limit-scroll>, which stops at the right end. A count before
213 C<.> is taken for a decimal point of the number by C<less>; give it
214 to the right arrow instead, as C<3> and the right arrow.
215  
216 The help of C<less> on C<h> and C<H> is then on no key, and C<g> and
217 C<G> no longer go to the first and the last line, which are on the
218 screen all the time anyway.
219  
220 When C<LESSKEY_CONTENT> is set, the keys are added after it, in a
221 C<#command> section, so that they win over the same keys there and
222 in F<~/.lesskey>; the other keys stay as they are.
223  
224 C<NUP_LESSKEY> gives the keys in place of those of C<nup>, in the
225 same way, and they do not change with the panes or the C<less>. Set
226 it empty not to add any keys, and C<LESSKEY_CONTENT> is left as it
227 is:
228  
229 export NUP_LESSKEY=
230  
231 The options are added to C<NUP_PAGER>, C<NUP_PAGE_PAGER> and
232 C<--pager> as well when the command is C<less>; another pager is used
233 as it is, and has to be told not to wrap the lines.
234  
235 See L</"LESS INTEGRATION"> for what works with the versions of
236 C<less>, and for the build of C<less> in tecolicom/tap, with which
237 the screens are the same as without C<-L>.
238  
239 nup -L man perlfunc
240 nup -L -C4 README.md
241  
242 With more than one file, or C<-V>, the files side by side go on to
243 the right in the same way, instead of going on below: each file is a
244 column of its own, without pages, and as many columns as without this
245 option are on the screen. The lines move up and down as usual, and
246 only C<h>, C<l>, C<,>, C<.>, the arrow keys, ESC-( and ESC-), C<H>,
247 C<L>, C<E<lt>> and C<E<gt>> are put in C<LESSKEY_CONTENT>, to move by one column and to
248 the ends; C<g> and C<G> go to the first and the last line.
249  
250 nup -L *.txt
251  
252 With C<--no-paginate> and one input, which has nothing to put on the
253 right, and with C<-o>, which writes the pages as without it, this
254 option is ignored. It cannot be used with rows (C<-R>, C<-C2,2>,
255 C<-G>) or PDF output (C<-T>).
256 C<--auto-paginate> is ignored. The pages are laid out once, for the
257 height of the terminal at that time.
258  
259 =item B<-H>, B<--filename>
260  
261 Show filename headers in file view mode. Enabled by default.
262 Use C<--no-filename> to disable.
263  
264 =back
265  
266 =head2 Layout Options
267  
268 =over 4
269  
270 =item B<-C> I<C>[,I<R>], B<--pane>=I<C>[,I<R>]
271  
272 Set the number of columns (panes), and the number of rows when it is
273 given after a comma. For example, C<-C2> creates 2 columns, and
274 C<-C2,3> creates 2 columns and 3 rows.
275  
276 =item B<-R> I<N>, B<--row>=I<N>
277  
278 Set the number of rows.
279 This option is kept for compatibility and may be removed in the
280 future.
281  
282 =item B<-G> I<CxR>, B<--grid>=I<CxR>
283  
284 Set grid layout. C<-G2x3> is equivalent to C<-C2,3>.
285 This option is kept for compatibility and may be removed in the
286 future.
287  
288 =item B<-P> I<N>, B<--page>=I<N>
289  
290 Set the page height in lines.
291  
292 =item B<-S> I<N>, B<--pane-width>=I<N>
293  
294 Set the pane width in characters. Default is 85.
295  
296 =item B<-w> I<N>, B<--width>=I<N>
297  
298 Set the output width in characters. It is given to C<ansicolumn>.
299 To set the width when no terminal is available, the C<COLUMNS>
300 environment variable works as well; see L</Terminal Size>.
301  
302 =item B<--ac> I<OPTIONS> ... B<-->, B<--column-opts> I<OPTIONS> ... B<-->
303  
304 Give other options to L<ansicolumn>. The arguments up to C<--> are
305 taken as they are, and the C<--> is removed:
306  
307 nup --column-opts --tabstop 4 -s : -- file
308 nup --column-opts --tabstop 4 -- man nup
309  
310 The options after the C<--> are those of C<nup> again. To end the
311 options there, give another C<-->. A single option can be given
312 without C<--> as C<--column-opts=--tabstop=4>.
313  
314 =back
315  
316 =head2 Style Options
317  
318 =over 4
319  
320 =item B<--bs>=I<STYLE>, B<--border-style>=I<STYLE>
321  
322 Set the border style. Default is C<heavy-box>.
323  
324 =item B<--ls>=I<STYLE>, B<--line-style>=I<STYLE>
325  
326 Set the line style. Available: C<none>, C<truncate>, C<wrap>, C<wordwrap>.
327  
328 =item B<--runin>=I<N>, B<--runout>=I<N>, B<--runlen>=I<N>
329  
330 Set the run-in and run-out widths that L<ansicolumn> uses for line
331 breaking (kinsoku) when it folds long lines. C<--runlen> sets both.
332 They are given to ansicolumn after the values in F<~/.ansicolumnrc>,
333 so they take precedence. Without them, ansicolumn uses the values in
334 F<~/.ansicolumnrc>, or 2.
335  
336 =item B<--boundary>=C<word>|C<space>|C<none>
337  
338 Set where L<ansicolumn> may break a line when it folds long lines, as
339 its C<--boundary> option: C<word> does not break inside an
340 alphanumeric word, C<space> not inside a sequence of non-space
341 characters, and C<none> breaks anywhere. Like C<--runin>, it is
342 given to ansicolumn after F<~/.ansicolumnrc>. Without it, ansicolumn
343 uses the value in the rc file, or C<word> in document mode.
344  
345 =item B<--cm>=I<SPEC>, B<--colormap>=I<SPEC>
346  
347 Set color mapping. Specify as C<LABEL=COLOR> (e.g., C<--cm=BORDER=R>).
348 Available labels: C<TEXT>, C<BORDER>.
349  
350 =item B<-->[B<no->]B<page-number>
351  
352 Show page number on the bottom border of each column, with the number
353 of all the pages, as C<3/12>. With the
354 files side by side (more than one file, or C<-V>), which can be long,
355 it is shown on the top border as well, at the left, under the file
356 name. Enabled by default. Use
357 C<--no-page-number> to disable.
358  
359 =item B<--white-board>, B<--black-board>, B<--green-board>, B<--slate-board>
360  
361 Predefined color schemes for board-style display.
362  
363 =back
364  
365 =head2 Text Conversion
366  
367 =over 4
368  
369 =item B<--textconv>[=I<EXT,...>]
370  
371 Enable text conversion for non-text files using
372 L<App::optex::textconv>. When any of the specified file extensions
373 are found in the arguments, the C<textconv> module is loaded to
374 convert them to text before display.
375  
376 Default extensions:
377 C<pdf,docx,docm,pptx,pptm,xlsx,xlsm,jpg,jpeg>.
378  
379 Use C<--textconv=none> to disable.
380  
381 =item B<--hi>, B<--highlight>[=I<NAME>], B<--no-highlight>
382  
383 Color the source files by their syntax in file view mode. Enabled
384 by default, and done when the command of the highlighter and
385 L<Text::ANSI::Highlight::IO> are installed; nothing changes without
386 them.
387 C<ansicolumn> reads each file through the highlighter, with the language
388 told from the name of the file, or from the first line of a script.
389 In a Markdown file, the code in a fence is colored by the language of
390 the fence.
391 A file whose language is not known is shown as it is, and so is a
392 file which has ANSI sequences already. The file names in the headers
393 are not changed.
394  
395 I<NAME> is the highlighter:
396  
397 pandoc pandoc, by its ansi writer (default)
398 sourcehighlight, gnu source-highlight of GNU Source-highlight,
399 the colors of less
400 skylighting, sky the skylighting command
401  
402 brew install pandoc
403 brew install source-highlight
404 brew install skylighting
405  
406 A style of the highlighter can be given after the name and a colon,
407 a name of its own or a file: C<--highlight=pandoc:breezedark> for a
408 dark screen, C<--hi=gnu:esc256>. See L<Text::ANSI::Highlight/STYLES>.
409  
410 Set the one to use in C<NUP_OPTS>:
411  
412 export NUP_OPTS=--highlight=sourcehighlight
413  
414 Use C<--no-highlight> to disable. C<--hi> is the short name of the
415 option, and C<sky> and C<gnu> are those of the highlighters:
416 C<--hi=gnu>, C<--no-hi>.
417  
418 =back
419  
420 =head2 Pager Options
421  
422 =over 4
423  
424 =item B<--pager>=I<COMMAND>
425  
426 Set the pager command. Default is C<NUP_PAGER> or C<less -F +Gg>.
427 When page mode is active, C<NUP_PAGE_PAGER> takes precedence over
428 C<NUP_PAGER>.
429 Viewing multiple files (or C<-V> parallel view) produces parallel
430 layout which has no page structure, so C<nup> disables page mode
431 and C<NUP_PAGE_PAGER> is not used there.
432 The C<PAGER> variable is not used to avoid an infinite loop when
433 C<PAGER> is set to C<nup>.
434 C<+Gg> makes C<less> read all input before displaying, so that C<-F>
435 and the percentage work; see L</"LESS INTEGRATION"> for the settings
436 of C<less>.
437  
438 Use C<--pager=> (empty) or C<--no-pager> to disable pager.
439  
440 =item B<--no-pager>
441  
442 Disable pager.
443  
444 =back
445  
446 =head2 PDF Output
447  
448 =over 4
449  
450 =item B<-T> I<DEVICE>, B<--device>=I<DEVICE>
451  
452 Set the device to show the output on. The default is C<tty>, the
453 terminal. Any other device is a paper, and the output is printed to
454 PDF by C<ansi2pdf>, instead of being shown on the terminal.
455  
456 The name of a paper is the one for the C<-p> option of C<ansi2pdf>,
457 such as C<a4>, C<a3>, C<b5> or C<letter>. A paper is used in
458 landscape orientation. The letter C<p> or C<l> after the name gives
459 the orientation: C<a4p> is A4 in portrait, and C<a4l> is A4 in
460 landscape. The device C<pdf> is the default paper of C<ansi2pdf>, A4.
461  
462 nup -T a4 man nup > nup.pdf # A4, landscape
463 nup -T a4p -C1 man nup | lpr # A4, portrait
464  
465 A sheet of paper takes the place of the terminal, and C<ansi2pdf>
466 takes the place of the pager. The size of a sheet in columns and
467 lines is asked to C<ansi2pdf>, the output is formatted for that size
468 in the same way as for a terminal, and each screen is printed on a
469 sheet as it is. The default is a landscape A4 sheet of 60 lines,
470 which has room for two panes of the default width.
471  
472 =item B<-o> I<FILE>, B<--output>=I<FILE>
473  
474 Write the output to I<FILE>. When the name ends with C<.pdf>, the
475 output is PDF without C<-T> as well.
476  
477 nup -o nup.pdf man nup # A4, landscape
478 nup -T a3 -o nup.pdf man nup # A3, landscape
479  
480 Otherwise, what is shown on the terminal is written to the file as it
481 is, with the ANSI sequences and in the size of the terminal, and the
482 pager is not used. C<-T tty> does so for a name ending with C<.pdf>
483 as well.
484  
485 nup -o nup.txt man nup # the same as --no-pager > nup.txt
486  
487 =item B<--geometry>
488  
489 Print the size of the device in columns and lines and its kind,
490 C<tty> or C<pdf>, and exit. No file is read and no command is run.
491  
492 $ nup -T a4p --geometry
493 100 60 pdf
494 $ nup -o nup.pdf -P 80 --geometry
495 275 80 pdf
496  
497 For a paper, the size is that of a sheet, which follows C<-T>, C<-o>,
498 C<-P>, C<-w>, the number of rows and C<--pdf-opts>. For the terminal,
499 it is the size of the terminal. This is for a program that formats
500 text before giving it to C<nup>, as L<mdee(1)|App::mdee> does.
501  
502 =item B<--pdf-opts>=I<OPTIONS>
503  
504 Give other options to C<ansi2pdf>, such as the number of lines on a
505 sheet, the margin and the fonts. They are given after the paper, so
506 they take precedence.
507  
508 nup -o nup.pdf --pdf-opts='-l 80 -m 15' man nup
509  
510 =back
511  
512 The C<-P> option sets the number of lines of a page for PDF as well:
513 a sheet has that many lines for each row. The C<-w> option sets the
514 number of columns of a sheet. The font size follows them, and the one
515 that is not given is decided to fill the sheet. With neither of them, a
516 sheet has 60 lines.
517  
518 nup -o nup.pdf -P 80 man nup # 80 lines on a sheet
519 nup -o nup.pdf -C2,2 -P 40 man nup # 2x2 pages of 40 lines
520 nup -o nup.pdf -C3 -w 300 file # 300 columns on a sheet
521  
522 =head2 Terminal Size
523  
524 The terminal size is taken from the controlling terminal
525 (C</dev/tty>). When it is not available, as when C<nup> is run
526 without a terminal, the C<COLUMNS> environment variable gives the
527 width (default 80), and C<LINES> gives the height (default 24) used
528 to split the screen when the number of rows is set, as in C<-C2,2>:
529  
530 COLUMNS=170 nup -C2 file1.txt file2.txt
531  
532 =head1 LESS INTEGRATION
533  
534 C<nup> is made to be used with C<less>. It sets environment
535 variables for C<less> (see L</ENVIRONMENT>), and adds options to it
536 for C<-L>. Some of them need a recent version, and a patched build
537 of C<less> does more for the pages of C<nup>.
538  
539 The pages fill the screen and go on below, and a line down would show
540 them cut in the middle. So C<j> and C<k>, the down and up arrows,
541 C<d> and C<u>, C<^D> and C<^U>, and the return key
542 move by the screen, as space and C<b> do, when the output has pages
543 and the pager is C<less> 661 or later, and C<J> and C<K> go to the
544 last and the first page, as C<G> and C<g>. The keys are put in
545 C<LESSKEY_CONTENT>, in the way C<-L> does, and not when C<NUP_LESSKEY>
546 is set. Without pages (C<-F>, or the files side by side), they move
547 by the line as usual. C<e> and C<y> are left to move by the line.
548  
549 =head2 Versions
550  
551 =over 4
552  
553 =item C<less> 590
554  
555 C<--file-size> makes C<less> read all input before displaying, as
556 C<+Gg> of the default pager does. The C<less> 581 of macOS does not
557 have it, so C<+Gg> is the default. Set C<NUP_PAGER> to use it:
558  
559 export NUP_PAGER="less --file-size"
560  
561 =item C<less> 661
562  
563 C<LESSKEY_CONTENT> is read, which C<-L> uses to put its keys:
564 C<h>, C<l>, C<,>, C<.>, the arrow keys, ESC-( and ESC-), C<H>, C<L>, C<g>, C<G>,
565 C<E<lt>>, C<E<gt>>, space, C<f>, C<b>, C<j>, C<k>, C<d>, C<u>, C<^D>, C<^U>,
566 the return key, C<J> and C<K>.
567 Without C<-L>, the keys are C<j>, C<k>, the down and up arrows, C<d>,
568 C<u>, C<^D>, C<^U>, the return key, C<J> and C<K>.
569 An older C<less> ignores it.
570  
571 =item C<less> 710
572  
573 C<right-limit-scroll> stops at the right end of the lines. C<-L>
574 puts it on C<l>, C<.>, the right arrow and ESC-), in place of C<right-scroll>,
575 which goes on past the end.
576  
577 =back
578  
579 C<nup> runs C<less> with C<--version> and the options below to see its
580 version, and whether it has them.
581  
582 =head2 The Build in tecolicom/tap
583  
584 L<tecolicom/tap|https://github.com/tecolicom/homebrew-tap> has a build
585 of C<less> with patches for the pages of C<nup>
586 (L<kaz-utashiro/less|https://github.com/kaz-utashiro/less>). It adds
587 two options:
588  
589 =over 4
590  
591 =item B<--align-record>=I<N>
592  
593 A search shows the whole record (page) that has the match from the
594 top of the screen, instead of the matching line, so that the pages
595 stay in place. I<N> is the lines of a record; C<-1> is the height
596 of the screen less the prompt line, which is the height of the pages
597 of C<nup>. A repeated search goes on from the next record.
598 C<nup> adds C<--align-record=-1> when the output has pages and the
599 C<less> has it, unless the option is given in the pager command or in
600 C<LESS>.
601  
602 =item B<--align-shift>
603  
604 The horizontal shift stays at a multiple of the C<--shift> amount, the
605 width of a pane with C<-L>, so that the panes are always at the edge
606 of the screen. C<-L> adds this option when the C<less> has it, and
607 the screens are then the same as without C<-L>: space, C<b>, C<G> and
608 C<E<gt>> move by the screens, the last screen shows the last pages
609 and the rest of it is blank, and C<n> and C<N> skip the matches on
610 the screen and move by the screens to the next page that has one.
611 C<l>, C<.> and the right arrow go on until the last page is at the left
612 edge. For this, the keys of C<-L> are given a count instead of being repeated:
613 with three panes, space and C<b>, and the keys which do the same, are
614 C<3> ESC-) and C<3> ESC-(, and
615 C<G> and C<E<gt>> are C<3L>, while C<L> shows the end of the row at
616 the right edge of the screen.
617  
618 =back
619  
620 C<app-nup> of the tap has it inside, and C<nup> of C<app-nup> runs it.
621 It is put apart from the commands of Homebrew, so the C<less> of
622 Homebrew itself stays as it is. To use it as C<less> outside of
623 C<nup>, install it on its own; it cannot be installed together with
624 the C<less> of Homebrew, which has the same command name:
625  
626 brew install tecolicom/tap/less
627  
628 With either, C<--file-size> can be used in place of C<+Gg>:
629  
630 export NUP_PAGER="less --file-size"
631  
632 =head1 ENVIRONMENT
633  
634 =head2 Read by C<nup>
635  
636 =over 4
637  
638 =item C<NUP_OPTS>
639  
640 Options given before those on the command line, separated by spaces,
641 so that the options on the command line take precedence. This is
642 useful when C<nup> is called by another command, as C<MANPAGER>:
643  
644 NUP_OPTS=-L man perlfunc
645  
646 =item C<NUP_PAGER>
647  
648 The pager command, used when C<--pager> is not given. Default:
649 C<less -F +Gg>. See C<--pager> in L</"Pager Options">.
650  
651 =item C<NUP_PAGE_PAGER>
652  
653 The pager command in page mode, used in place of C<NUP_PAGER>. See
654 C<--pager> in L</"Pager Options">.
655  
656 =item C<NUP_LESSKEY>
657  
658 The keys that C<-L> gives to C<less>, in place of those of C<nup>.
659 Empty for no keys. See C<-L> in L</"General Options">. When it is
660 set, the keys of the pages without C<-L> are not added either.
661  
662 =item C<COLUMNS>, C<LINES>
663  
664 The width and the height of the terminal when C</dev/tty> is not
665 available. See L</Terminal Size>.
666  
667 =back
668  
669 C<PAGER> is not read, so that it can be set to C<nup>.
670  
671 =head2 Set by C<nup>
672  
673 These are set for C<less>, when they are not set already:
674  
675 =over 4
676  
677 =item C<LESS>
678  
679 Default: C<-R>. Required for ANSI color sequences.
680  
681 =item C<LESSANSIENDCHARS>
682  
683 Default: C<mK>. Recognizes SGR (C<m>) and erase line (C<K>)
684 sequences.
685  
686 =back
687  
688 C<-L> adds its keys to C<LESSKEY_CONTENT>, after those already in
689 it. See C<-L> in L</"General Options">.
690  
691 =head1 EXAMPLES
692  
693 Typical n-up usage:
694  
695 nup man nup # view manual in n-up layout
696 nup -C2 man perl # 2 columns
697 nup -C2,2 man perl # 2x2 grid (4-up layout)
698 nup -F man perl # no pagination
699 nup -L man perl # one row of pages, scrolled sideways
700 nup -L -C4 man perl # four pages on the screen at a time
701 nup -L *.txt # files side by side, scrolled sideways
702 nup file1.txt file2.txt # view files side by side
703 nup -C2 -w 170 a.txt b.txt # 2 columns, width 170
704 nup -e ./script.sh # force command mode for a file
705 nup -o nup.pdf man nup # print to PDF (requires ansi2pdf)
706 nup -T a4p -C1 file | lpr # print on A4 in portrait
707  
708 Using C<nup> as a C<MANPAGER>:
709  
710 export MANPAGER="nup -A"
711  
712 =head1 INSTALLATION
713  
714 =head2 Homebrew
715  
716 Use L<tecolicom/tap|https://github.com/tecolicom/homebrew-tap>:
717  
718 brew tap tecolicom/tap
719 brew install app-nup
720  
721 It comes with the build of C<less> in the same tap, which C<nup> runs;
722 see L</"LESS INTEGRATION">.
723  
724 =head2 CPAN
725  
726 Using L<cpanminus|https://metacpan.org/pod/App::cpanminus>:
727  
728 cpanm -n App::nup
729  
730 =head1 DIAGNOSTICS
731  
732 Both stdout and stderr of the command are merged and passed through
733 the n-up output filter. Error messages will appear in the paged output.
734  
735 =head1 EXIT STATUS
736  
737 The exit status of the executed command is not preserved because
738 the output is passed through a filter pipeline.
739  
740 =head1 SEE ALSO
741  
742 L<App::optex::up> (bundled), L<optex>
743  
744 =head1 AUTHOR
745  
746 Kazumasa Utashiro
747  
748 =head1 LICENSE
749  
750 Copyright © 2025-2026 Kazumasa Utashiro.
751  
752 This software is released under the MIT License.
753 L<https://opensource.org/licenses/MIT>
754  
755 =cut
« blib/lib/App/optex/up.pm ↑ Summary