Improve docs, add info about miltiple types

This commit is contained in:
Nikita Ivanov 2022-07-14 01:12:43 +05:00
parent 965d42cc3d
commit b326e32100
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -248,23 +248,23 @@ uses a configuration file usually located at
.IR FILES ). .IR FILES ).
Its format somewhat resembles one used by Its format somewhat resembles one used by
.IR lf . .IR lf .
There are several \(lqcommands\(rq that can be used to change There are several commands that can be used to add
previews or set different settings. previews or set different settings.
Commands are separated by newlines. Commands are separated by newlines.
Comments start with number sign Comments start with number sign
.RB ( # ). .RB \(lq # \(rq.
. .
.PP .PP
Example: Example:
. .
.IP
.EX .EX
.IP
# Set an option # Set an option
set forcekitty set forcekitty
.IP .IP
# Add a new preview for man pages (like this one) # Add a new preview
preview manpage .1 {{ preview cow .moo {{
\& groff -man -tep -Tutf8 -rLL="${w}n" "${f}" | col -x \& cowsay < "$f"
}} }}
.IP .IP
# Remove some previews # Remove some previews
@ -315,39 +315,43 @@ Filename must have \(lq.gpg\(rq extension.
. .
.SS Defining custom previews .SS Defining custom previews
. .
A snippet below defines a new preview with name User-defined previews are added with
.I cow .B preview
that applies to files with extension command.
.IR .moo . .
.PP
An example below defines a new preview with name \(lqmanpage\(rq
that applies to files with extension \(lq.1\(rq.
A preview itself is a shell script enclosed within double curly A preview itself is a shell script enclosed within double curly
braces (this particular one utilizes the famous braces.
.I cowsay
program):
. .
.IP .IP
.EX .EX
preview cow .moo {{ preview manpage .1 {{
\& cowsay < "$f" \& groff -man -tep -Tutf8 -rLL="${w}n" "${f}" | col -x
}} }}
.EE .EE
. .
.PP .PP
Running Running
.I "ctpv\ file.moo" .I "ctpv\ file.1"
where where
.I file.moo .I file.1
contains \(lqsome text\(rq will produce the following output: is a source code for a manpage will run
.BR groff (1)
to produce a formatted manpage like the one you are reading.
.
.PP
Manpages filenames may also end with other extensions:
\(lq.2\(rq,\(lq.3\(rq,\(lq.4\(rq and so on.
It's possible to make user-defines previews apply to several
file types at once:
. .
.IP .IP
.EX .EX
\& ___________ preview manpage .1 .2 .3 .4 .5 .6 .7 .8 {{
\&< some text > \& # groff command
\& ----------- }}
\& \\ ^__^
\& \\ (oo)\\_______
\& (__)\\ )\\/\\
\& ||----w |
\& || ||
.EE .EE
. .
.PP .PP
@ -401,7 +405,7 @@ preview json_example application/json {{
.PP .PP
You can omit subtype part of the MIME type You can omit subtype part of the MIME type
by replacing it with by replacing it with
.BR * . .RB \(lq * \(rq.
. .
.IP .IP
.EX .EX
@ -412,8 +416,8 @@ preview any_text_example text/* {{
. .
.PP .PP
Setting subtype to Setting subtype to
.B * .RB \(lq * \(rq
will make the preview above work for any file which MIME type starts with will make the preview above apply to any file which MIME type starts with
.BR text/ . .BR text/ .
. .
.SS Setting priority .SS Setting priority