Add documentation
This commit is contained in:
1 file changed
+33
-23
@@ -291,6 +291,8 @@ The following options can be used to customize the behavior of lf:
|
|||||||
number bool (default false)
|
number bool (default false)
|
||||||
numberfmt string (default "\033[33m")
|
numberfmt string (default "\033[33m")
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
|
preload bool (default false)
|
||||||
|
preloader string (default '')
|
||||||
preserve []string (default "mode")
|
preserve []string (default "mode")
|
||||||
preview bool (default true)
|
preview bool (default true)
|
||||||
previewer string (default '')
|
previewer string (default '')
|
||||||
@@ -1038,6 +1040,18 @@ Note that directories are already updated automatically in many cases.
|
|||||||
This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf.
|
This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf.
|
||||||
Periodic checks are disabled when the value of this option is set to zero.
|
Periodic checks are disabled when the value of this option is set to zero.
|
||||||
|
|
||||||
|
## preload (bool) (default false)
|
||||||
|
|
||||||
|
Allow previews to be generated in advance using the `preloader` script as the user navigates through the filesystem.
|
||||||
|
|
||||||
|
## preloader (string) (default ``) (not filtered if empty)
|
||||||
|
|
||||||
|
Set the path of a preloader file to preload file previews.
|
||||||
|
The file should be executable.
|
||||||
|
This is called in the same way as the `previewer` file (see the `previewer` option for more details).
|
||||||
|
If the exit code is zero, the output will be cached and displayed by lf without calling the `previewer`.
|
||||||
|
Otherwise, the preview will be managed using the `previewer` and `cleaner`.
|
||||||
|
|
||||||
## preserve ([]string) (default `mode`)
|
## preserve ([]string) (default `mode`)
|
||||||
|
|
||||||
List of attributes that are preserved when copying files.
|
List of attributes that are preserved when copying files.
|
||||||
@@ -1906,19 +1920,8 @@ For coloring lf recognizes ANSI escape codes.
|
|||||||
To use this feature, you need to set the value of `previewer` option to the path of an executable file.
|
To use this feature, you need to set the value of `previewer` option to the path of an executable file.
|
||||||
Five arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
Five arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||||
The output of the execution is printed in the preview pane.
|
The output of the execution is printed in the preview pane.
|
||||||
You may also want to use the same script in your pager mapping as well:
|
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
Different types of files can be handled by matching by extension (or MIME type from the `file` command):
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
|
||||||
|
|
||||||
For `less` pager, you may instead utilize `LESSOPEN` mechanism so that useful information about the file such as the full path of the file can still be displayed in the statusline below:
|
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
|
||||||
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
|
||||||
|
|
||||||
Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user.
|
|
||||||
You may use file extensions to determine the type of file more efficiently compared to obtaining MIME types from `file` command.
|
|
||||||
Extensions can then be used to match cleanly within a conditional:
|
|
||||||
|
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
@@ -1931,21 +1934,28 @@ Extensions can then be used to match cleanly within a conditional:
|
|||||||
*) highlight -O ansi "$1";;
|
*) highlight -O ansi "$1";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
Another important consideration for efficiency is the use of programs with short startup times for preview.
|
Because files can be large, lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
|
||||||
For this reason, `highlight` is recommended over `pygmentize` for syntax highlighting.
|
Note that some programs may not respond well to SIGPIPE and will exit with a non-zero return code, which avoids caching.
|
||||||
Besides, it is also important that the application processes the file on the fly rather than first reading it to the memory and then doing the processing afterwards.
|
|
||||||
This is especially relevant for big files.
|
|
||||||
lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
|
|
||||||
When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.
|
|
||||||
Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching.
|
|
||||||
You may add a trailing `|| true` command to avoid such errors:
|
You may add a trailing `|| true` command to avoid such errors:
|
||||||
|
|
||||||
highlight -O ansi "$1" || true
|
highlight -O ansi "$1" || true
|
||||||
|
|
||||||
You may also use an existing preview filter as you like.
|
You may also want to use the same script in your pager mapping as well:
|
||||||
Your system may already come with a preview filter named `lesspipe`.
|
|
||||||
These filters may have a mechanism to add user customizations as well.
|
set previewer ~/.config/lf/pv.sh
|
||||||
See the related documentation for more information.
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
|
|
||||||
|
For `less` pager, you may instead utilize `LESSOPEN` mechanism so that useful information about the file such as the full path of the file can still be displayed in the statusline below:
|
||||||
|
|
||||||
|
set previewer ~/.config/lf/pv.sh
|
||||||
|
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||||
|
|
||||||
|
Since the preview script is called for each file selection change, it may not generate previews fast enough if the user scrolls through files quickly.
|
||||||
|
In this case the `preload` and `preloader` options can be set to enable file previews to be preloaded in advance.
|
||||||
|
If enabled, the preload script will be run on files in advance as the user navigates through them.
|
||||||
|
The preload script receives the same arguments as the preview script.
|
||||||
|
If the exit code of the preload script is zero, then the output will be cached in memory and displayed by lf (useful for text or sixel previews).
|
||||||
|
If the exit code of the preload script is not zero, then it will fallback to using the preview script instead (useful for previews managed by an external program).
|
||||||
|
|
||||||
# CHANGING DIRECTORY
|
# CHANGING DIRECTORY
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user