From 9698ecddf17c5fdff78494314bd2a718b4100f3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6k=C3=A7ehan=20Kara?= Date: Sun, 12 Nov 2023 15:43:06 +0100 Subject: [PATCH] use markdown for the documentation (#1474) * add doc.md * use h2 for doc sections * use h3 for doc commands/options/vars * use backticks instead of quotes in the doc * merge multiple commands/options in the doc * change header levels in the doc * add man page sections to the doc * remove extra spaces in headers in the doc * add man and plain conversions of the doc * update doc * add missing flags to the doc * replace the old documentation with the new one * remove old doc files * remove the doc instructions from CONTRIBUTING.md * change the links to the doc * shorten long links in the readme --- CONTRIBUTING.md | 11 - README.md | 6 +- doc.go => doc.md | 791 +++++----- doc.txt | 2258 +++++++++++++++++++++++++++++ docstring.go | 1989 -------------------------- gen/doc.sh | 30 + gen/docstring.sh | 19 - gen/man.sh | 75 - lf.1 | 3575 +++++++++++++++++++++++++--------------------- main.go | 5 + 10 files changed, 4667 insertions(+), 4092 deletions(-) rename doc.go => doc.md (70%) create mode 100644 doc.txt delete mode 100644 docstring.go create mode 100755 gen/doc.sh delete mode 100755 gen/docstring.sh delete mode 100755 gen/man.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df849a19..1182ccc9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,14 +49,3 @@ Adding a new command usually requires the following steps: There are two files named `os.go` and `os_windows.go` for unix and windows specific code respectively. If you add something to either of these files but not the other, you probably break the build for the other platform. If your addition works the same in both platforms, your addition probably belongs to `main.go` instead. - -## Make changes to the documentation - -There are three files that contain the documentation in various formats: - -- `doc.go` is the source of the [online documentation](https://pkg.go.dev/github.com/gokcehan/lf) -- `docstring.go` is used when running `lf -doc` -- `lf.1` is a man page which is commonly available on Unix-like operating systems (`man lf`) - -You should only make changes to `doc.go`, the other files are automatically generated **and should not be edited manually**. -Run `go fmt && go generate` to ensure that the code is formatted and files are generated correctly. diff --git a/README.md b/README.md index feffdec3..3efba4bb 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # LF [Google Groups](https://groups.google.com/forum/#!forum/lf-fm) +| [Doc](doc.md) | [Wiki](https://github.com/gokcehan/lf/wiki) | [#lf](https://web.libera.chat/#lf) (on Libera.Chat) | [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge) [![Go Build](https://github.com/gokcehan/lf/actions/workflows/go.yml/badge.svg)](https://github.com/gokcehan/lf/actions/workflows/go.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/gokcehan/lf)](https://goreportcard.com/report/github.com/gokcehan/lf) -[![Go Reference](https://pkg.go.dev/badge/github.com/gokcehan/lf.svg)](https://pkg.go.dev/github.com/gokcehan/lf) `lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager. See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts. @@ -24,7 +24,7 @@ See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tut - Server/client architecture and remote commands to manage multiple instances - Extendable and configurable with shell commands - Customizable keybindings (vi and readline defaults) -- A reasonable set of other features (see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf)) +- A reasonable set of other features (see the [documentation](doc.md)) ## Non-Features @@ -66,7 +66,7 @@ After the installation `lf` command should start the application in the current Run `lf -help` to see command line options. -Run `lf -doc` to see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf). +Run `lf -doc` to see the [documentation](doc.md). See [etc](etc) directory to integrate `lf` to your shell and/or editor. Example configuration files along with example colors and icons files can also be found in this directory. diff --git a/doc.go b/doc.md similarity index 70% rename from doc.go rename to doc.md index 3cab825e..aece7636 100644 --- a/doc.go +++ b/doc.md @@ -1,18 +1,40 @@ -//go:generate gen/docstring.sh -//go:generate gen/man.sh +# NAME + +lf - terminal file manager + +# SYNOPSIS + +**lf** +[**-command** *command*] +[**-config** *path*] +[**-cpuprofile** *path*] +[**-doc**] +[**-last-dir-path** *path*] +[**-log path**] +[**-memprofile** *path*] +[**-print-last-dir**] +[**-print-selection**] +[**-remote** *command*] +[**-selection-path** *path*] +[**-server**] +[**-single**] +[**-version**] +[**-help**] +[*cd-or-select-path*] + +# DESCRIPTION -/* lf is a terminal file manager. Source code can be found in the repository at https://github.com/gokcehan/lf -This documentation can either be read from terminal using 'lf -doc' or online at https://pkg.go.dev/github.com/gokcehan/lf -You can also use 'doc' command (default '') inside lf to view the documentation in a pager. +This documentation can either be read from terminal using `lf -doc` or online at https://github.com/gokcehan/lf/blob/master/doc.md +You can also use `doc` command (default ``) inside lf to view the documentation in a pager. A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1 -You can run 'lf -help' to see descriptions of command line options. +You can run `lf -help` to see descriptions of command line options. -# Quick Reference +# QUICK REFERENCE The following commands are provided by lf: @@ -252,7 +274,7 @@ The following additional keybindings are provided by default: map gh cd ~ map :toggle; down -If the 'mouse' option is enabled, mouse buttons have the following default effects: +If the `mouse` option is enabled, mouse buttons have the following default effects: Left mouse button Click on a file or directory to select it. @@ -263,7 +285,7 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec Scroll wheel Move up or down. If Ctrl is pressed, scroll up or down. -# Configuration +# CONFIGURATION Configuration files should be located at: @@ -325,353 +347,325 @@ You can configure these locations with the following variables given with their A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example -# Commands +# COMMANDS This section shows information about builtin commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings. - quit (default 'q') +## quit (default `q`) Quit lf and return to the shell. - up (default 'k' and '') - half-up (default '') - page-up (default '' and '') - scroll-up (default '') - down (default 'j' and '') - half-down (default '') - page-down (default '' and '') - scroll-down (default '') +## up (default `k` and ``), half-up (default ``), page-up (default `` and ``), scroll-up (default ``), down (default `j` and ``), half-down (default ``), page-down (default `` and ``), scroll-down (default ``) Move/scroll the current file selection upwards/downwards by one/half a page/full page. - updir (default 'h' and '') +## updir (default `h` and ``) Change the current working directory to the parent directory. - open (default 'l' and '') +## open (default `l` and ``) -If the current file is a directory, then change the current directory to it, otherwise, execute the 'open' command. -A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument. -A custom 'open' command can be defined to override this default. +If the current file is a directory, then change the current directory to it, otherwise, execute the `open` command. +A default `open` command is provided to call the default system opener asynchronously with the current file as the argument. +A custom `open` command can be defined to override this default. - jump-next (default ']') - jump-prev (default '[') +## jump-next (default `]`), jump-prev (default `[`) Change the current working directory to the next/previous jumplist item. - top (default 'gg' and '') - bottom (default 'G' and '') +## top (default `gg` and ``), bottom (default `G` and ``) Move the current file selection to the top/bottom of the directory. A count can be specified to move to a specific line, for example use `3G` to move to the third line. - high (default 'H') - middle (default 'M') - low (default 'L') +## high (default `H`), middle (default `M`), low (default `L`) Move the current file selection to the high/middle/low of the screen. - toggle +## toggle Toggle the selection of the current file or files given as arguments. - invert (default 'v') +## invert (default `v`) -Reverse the selection of all files in the current directory (i.e. 'toggle' all files). +Reverse the selection of all files in the current directory (i.e. `toggle` all files). Selections in other directories are not effected by this command. -You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories. +You can define a new command to select all files in the directory by combining `invert` with `unselect` (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories. - invert-below +## invert-below -Reverse the selection (i.e. 'toggle') of all files at or after the current file in the current directory. +Reverse the selection (i.e. `toggle`) of all files at or after the current file in the current directory. To select a contiguous block of files, use this command on the first file you want to select. Then, move down to the first file you do *not* want to select (the one after the end of the desired selection) and use this command again. This achieves an effect similar to the visual mode in vim. -This command is experimental and may be removed once a better replacement for the visual mode is implemented in 'lf'. -If you'd like to experiment with using this command, you should bind it to a key (e.g. 'V') for a better experience. +This command is experimental and may be removed once a better replacement for the visual mode is implemented in `lf`. +If you'd like to experiment with using this command, you should bind it to a key (e.g. `V`) for a better experience. - unselect (default 'u') +## unselect (default `u`) Remove the selection of all files in all directories. - glob-select - glob-unselect +## glob-select, glob-unselect Select/unselect files that match the given glob. - calcdirsize +## calcdirsize Calculate the total size for each of the selected directories. -Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size. -If the total size of a directory is not calculated, it will be shown as '-'. +Option `info` should include `size` and option `dircounts` should be disabled to show this size. +If the total size of a directory is not calculated, it will be shown as `-`. - clearmaps +## clearmaps Remove all keybindings associated with the `map` command. This command can be used in the config file to remove the default keybindings. For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`. - copy (default 'y') +## copy (default `y`) If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files. - cut (default 'd') +## cut (default `d`) If there are no selections, save the path of the current file to the cut buffer, otherwise, copy the paths of selected files. - paste (default 'p') +## paste (default `p`) Copy/Move files in copy/cut buffer to the current working directory. -A custom 'paste' command can be defined to override this default. +A custom `paste` command can be defined to override this default. - clear (default 'c') +## clear (default `c`) Clear file paths in copy/cut buffer. - sync +## sync Synchronize copied/cut files with server. This command is automatically called when required. - draw +## draw Draw the screen. This command is automatically called when required. - redraw (default '') +## redraw (default ``) Synchronize the terminal and redraw the screen. - load +## load Load modified files and directories. This command is automatically called when required. - reload (default '') +## reload (default ``) Flush the cache and reload all files and directories. - echo +## echo Print given arguments to the message line at the bottom. - echomsg +## echomsg Print given arguments to the message line at the bottom and also to the log file. - echoerr +## echoerr -Print given arguments to the message line at the bottom as 'errorfmt' and also to the log file. +Print given arguments to the message line at the bottom as `errorfmt` and also to the log file. - cd +## cd Change the working directory to the given argument. - select +## select Change the current file selection to the given argument. - delete (modal) +## delete (modal) Remove the current file or selected file(s). -A custom 'delete' command can be defined to override this default. +A custom `delete` command can be defined to override this default. - rename (modal) (default 'r') +## rename (modal) (default `r`) Rename the current file using the builtin method. -A custom 'rename' command can be defined to override this default. +A custom `rename` command can be defined to override this default. - source +## source Read the configuration file given in the argument. - push +## push Simulate key pushes given in the argument. - read (modal) (default ':') +## read (modal) (default `:`) Read a command to evaluate. - shell (modal) (default '$') +## shell (modal) (default `$`) Read a shell command to execute. - shell-pipe (modal) (default '%') +## shell-pipe (modal) (default `%`) Read a shell command to execute piping its standard I/O to the bottom statline. - shell-wait (modal) (default '!') +## shell-wait (modal) (default `!`) Read a shell command to execute and wait for a key press in the end. - shell-async (modal) (default '&') +## shell-async (modal) (default `&`) Read a shell command to execute asynchronously without standard I/O. - find (modal) (default 'f') - find-back (modal) (default 'F') - find-next (default ';') - find-prev (default ',') +## find (modal) (default `f`), find-back (modal) (default `F`), find-next (default `;`), find-prev (default `,`) Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match. - search (default '/') - search-back (default '?') - search-next (default 'n') - search-prev (default 'N') +## search (default `/`), search-back (default `?`), search-next (default `n`), search-prev (default `N`) Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match. - filter (modal) - setfilter +## filter (modal), setfilter -Command 'filter' reads a pattern to filter out and only view files matching the pattern. -Command 'setfilter' does the same but uses an argument to set the filter immediately. -You can supply an argument to 'filter', in order to use that as the starting prompt. +Command `filter` reads a pattern to filter out and only view files matching the pattern. +Command `setfilter` does the same but uses an argument to set the filter immediately. +You can supply an argument to `filter`, in order to use that as the starting prompt. - mark-save (modal) (default 'm') +## mark-save (modal) (default `m`) Save the current directory as a bookmark assigned to the given key. - mark-load (modal) (default "'") +## mark-load (modal) (default `'`) Change the current directory to the bookmark assigned to the given key. -A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command. +A special bookmark `'` holds the previous directory after a `mark-load`, `cd`, or `select` command. - mark-remove (modal) (default '"') +## mark-remove (modal) (default `"`) Remove a bookmark assigned to the given key. - tag +## tag -Tag a file with '*' or a single width character given in the argument. -You can define a new tag clearing command by combining 'tag' with 'tag-toggle' (i.e. 'cmd tag-clear :tag; tag-toggle'). +Tag a file with `*` or a single width character given in the argument. +You can define a new tag clearing command by combining `tag` with `tag-toggle` (i.e. `cmd tag-clear :tag; tag-toggle`). - tag-toggle (default 't') +## tag-toggle (default `t`) -Tag a file with '*' or a single width character given in the argument if the file is untagged, otherwise remove the tag. +Tag a file with `*` or a single width character given in the argument if the file is untagged, otherwise remove the tag. -# Command Line Commands +# COMMAND LINE COMMANDS The prompt character specifies which of the several command-line modes you are in. -For example, the 'read' command takes you to the ':' mode. +For example, the `read` command takes you to the `:` mode. -When the cursor is at the first character in ':' mode, pressing one of the keys '!', '$', '%', or '&' takes you to the corresponding mode. -You can go back with 'cmd-delete-back' ('' by default). +When the cursor is at the first character in `:` mode, pressing one of the keys `!`, `$`, `%`, or `&` takes you to the corresponding mode. +You can go back with `cmd-delete-back` (`` by default). The command line commands should be mostly compatible with readline keybindings. A character refers to a unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters. - cmd-escape (default '') +## cmd-escape (default ``) Quit command line mode and return to normal mode. - cmd-complete (default '') +## cmd-complete (default ``) Autocomplete the current word. - cmd-menu-complete - cmd-menu-complete-back +## cmd-menu-complete, cmd-menu-complete-back Autocomplete the current word with menu selection. -You need to assign keys to these commands (e.g. 'cmap cmd-menu-complete; cmap cmd-menu-complete-back'). +You need to assign keys to these commands (e.g. `cmap cmd-menu-complete; cmap cmd-menu-complete-back`). You can use the assigned keys assigned to display the menu and then cycle through completion options. - cmd-menu-accept +## cmd-menu-accept Accept the currently selected match in menu completion and close the menu. - cmd-enter (default '' and '') +## cmd-enter (default `` and ``) Execute the current line. - cmd-interrupt (default '') +## cmd-interrupt (default ``) Interrupt the current shell-pipe command and return to the normal mode. - cmd-history-next (default '' and '') - cmd-history-prev (default '' and '') +## cmd-history-next (default `` and ``), cmd-history-prev (default `` and ``) Go to next/previous item in the history. - cmd-left (default '' and '') - cmd-right (default '' and '') +## cmd-left (default `` and ``), cmd-right (default `` and ``) Move the cursor to the left/right. - cmd-home (default '' and '') - cmd-end (default '' and '') +## cmd-home (default `` and ``), cmd-end (default `` and ``) Move the cursor to the beginning/end of line. - cmd-delete (default '' and '') +## cmd-delete (default `` and ``) Delete the next character. - cmd-delete-back (default '' and '') +## cmd-delete-back (default `` and ``) Delete the previous character. -When at the beginning of a prompt, returns either to normal mode or to ':' mode. +When at the beginning of a prompt, returns either to normal mode or to `:` mode. - cmd-delete-home (default '') - cmd-delete-end (default '') +## cmd-delete-home (default ``), cmd-delete-end (default ``) Delete everything up to the beginning/end of line. - cmd-delete-unix-word (default '') +## cmd-delete-unix-word (default ``) Delete the previous unix word. - cmd-yank (default '') +## cmd-yank (default ``) Paste the buffer content containing the last deleted item. - cmd-transpose (default '') - cmd-transpose-word (default '') +## cmd-transpose (default ``), cmd-transpose-word (default ``) Transpose the positions of last two characters/words. - cmd-word (default '') - cmd-word-back (default '') +## cmd-word (default ``), cmd-word-back (default ``) Move the cursor by one word in forward/backward direction. - cmd-delete-word (default '') +## cmd-delete-word (default ``) Delete the next word in forward direction. - cmd-delete-word-back (default '' and '') +## cmd-delete-word-back (default `` and ``) Delete the previous word in backward direction. - cmd-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') +## cmd-capitalize-word (default ``), cmd-uppercase-word (default ``), cmd-lowercase-word (default ``) Capitalize/uppercase/lowercase the current word and jump to the next word. -# Options +# OPTIONS This section shows information about options to customize the behavior. -Character ':' is used as the separator for list options '[]int' and '[]string'. +Character `:` is used as the separator for list options `[]int` and `[]string`. - anchorfind bool (default true) +## anchorfind (bool) (default true) When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position. - autoquit bool (default false) +## autoquit (bool) (default false) Automatically quit server when there are no clients left connected. - borderfmt string (default "\033[0m") +## borderfmt (string) (default `\033[0m`) Format string of the box drawing characters enabled by the `drawbox` option. - cleaner string (default '') (not called if empty) +## cleaner (string) (default ``) (not called if empty) Set the path of a cleaner file. The file should be executable. @@ -679,9 +673,7 @@ This file is called if previewing is enabled, the previewer is set, and the prev The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively. Preview cleaning is disabled when the value of this option is left empty. - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") +## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt string (default `\033[7m`), cursorpreviewfmt string (default `\033[4m`) Format strings for highlighting the cursor. `cursoractivefmt` applies in the current directory pane, @@ -690,160 +682,160 @@ and `cursorpreviewfmt` applies in panes that preview directories. The default is to make the active cursor and the parent directory cursor inverted. The preview cursor is underlined. -Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, "\033[7;2m" for dimmed inverted text (visibility varies by terminal), "\033[7;90m" for inverted text with grey (aka "brightblack") background. +Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, `\033[7;2m` for dimmed inverted text (visibility varies by terminal), `\033[7;90m` for inverted text with grey (aka "brightblack") background. If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. -For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". +For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`. - dircache bool (default true) +## dircache (bool) (default true) Cache directory contents. - dircounts bool (default false) +## dircounts (bool) (default false) -When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using 'calcdirsize'. +When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`. This information needs to be calculated by reading the directory and counting the items inside. Therefore, this option is disabled by default for performance reasons. -This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. -999 items are counted per directory at most, and bigger directories are shown as '999+'. +This option only has an effect when `info` has a `size` field and the pane is wide enough to show the information. +999 items are counted per directory at most, and bigger directories are shown as `999+`. - dirfirst bool (default true) +## dirfirst (bool) (default true) Show directories first above regular files. - dironly bool (default false) +## dironly (bool) (default false) Show only directories. - dirpreviews bool (default false) +## dirpreviews (bool) (default false) If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. - drawbox bool (default false) +## drawbox (bool) (default false) Draw boxes around panes with box drawing characters. - dupfilefmt string (default '%f.~%n~') +## dupfilefmt (string) (default `%f.~%n~`) Format string of file name when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`. -Special expansions are provided, '%f' as the file name, '%b' for basename (file name without extension), '%e' as the extension (including the dot) and '%n' as the number of duplicates. +Special expansions are provided, `%f` as the file name, `%b` for basename (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates. - errorfmt string (default "\033[7;31;47m") +## errorfmt (string) (default `\033[7;31;47m`) Format string of error messages shown in the bottom message line. If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. -For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". +For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`. - filesep string (default "\n") +## filesep (string) (default `\n`) -File separator used in environment variables 'fs' and 'fx'. +File separator used in environment variables `fs` and `fx`. - findlen int (default 1) +## findlen (int) (default 1) Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left. - globsearch bool (default false) +## globsearch (bool) (default false) When this option is enabled, search command patterns are considered as globs, otherwise they are literals. -With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...]' matches character sets or ranges. +With globbing, `*` matches any sequence, `?` matches any character, and `[...]` or `[^...]` matches character sets or ranges. Otherwise, these characters are interpreted as they are. - hidden bool (default false) +## hidden (bool) (default false) Show hidden files. -On Unix systems, hidden files are determined by the value of 'hiddenfiles'. +On Unix systems, hidden files are determined by the value of `hiddenfiles`. On Windows, only files with hidden attributes are considered hidden files. - hiddenfiles []string (default '.*') +## hiddenfiles ([]string) (default `.*`) List of hidden file glob patterns. Patterns can be given as relative or absolute paths. -Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...]' to match character sets or ranges. -In addition, if a pattern starts with '!', then its matches are excluded from hidden files. To add multiple patterns, use ':' as a separator. Example: '.*:lost+found:*.bak' +Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges. +In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak` - history bool (default true) +## history (bool) (default true) Save command history. - icons bool (default false) +## icons (bool) (default false) Show icons before each item in the list. - ifs string (default '') +## ifs (string) (default ``) -Sets 'IFS' variable in shell commands. -It works by adding the assignment to the beginning of the command string as "IFS='...'; ...". -The reason is that 'IFS' variable is not inherited by the shell for security reasons. +Sets `IFS` variable in shell commands. +It works by adding the assignment to the beginning of the command string as `IFS=...; ...`. +The reason is that `IFS` variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on Windows. - ignorecase bool (default true) +## ignorecase (bool) (default true) Ignore case in sorting and search patterns. - ignoredia bool (default true) +## ignoredia (bool) (default true) Ignore diacritics in sorting and search patterns. - incsearch bool (default false) +## incsearch (bool) (default false) Jump to the first match after each keystroke during searching. - incfilter bool (default false) +## incfilter (bool) (default false) Apply filter pattern after each keystroke during filtering. - info []string (default '') +## info ([]string) (default ``) List of information shown for directory items at the right side of pane. -Currently supported information types are 'size', 'time', 'atime', and 'ctime'. +Currently supported information types are `size`, `time`, `atime`, and `ctime`. Information is only shown when the pane width is more than twice the width of information. - infotimefmtnew string (default 'Jan _2 15:04') +## infotimefmtnew (string) (default `Jan _2 15:04`) Format string of the file time shown in the info column when it matches this year. - infotimefmtold string (default 'Jan _2 2006') +## infotimefmtold (string) (default `Jan _2 2006`) Format string of the file time shown in the info column when it doesn't match this year. - mouse bool (default false) +## mouse (bool) (default false) Send mouse events as input. - number bool (default false) +## number (bool) (default false) Show the position number for directory items at the left side of pane. -When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. +When `relativenumber` option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. - numberfmt string (default "\033[33m") +## numberfmt (string) (default `\033[33m`) Format string of the position number for each line. - period int (default 0) +## period (int) (default 0) Set the interval in seconds for periodic checks of directory updates. -This works by periodically calling the 'load' command. +This works by periodically calling the `load` command. 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. Periodic checks are disabled when the value of this option is set to zero. - preserve []string (default 'mode') +## preserve ([]string) (default `mode`) List of attributes that are preserved when copying files. -Currently supported attributes are 'mode' (i.a. access mode) and 'timestamps' (i.e. modification time and access time). +Currently supported attributes are `mode` (i.a. access mode) and `timestamps` (i.e. modification time and access time). Note, preserving other attribute like ownership of change/birth timestamp is desirable, but not portably supported in Go. - preview bool (default true) +## preview (bool) (default true) Show previews of files and directories at the right most pane. If the file has more lines than the preview pane, rest of the lines are not read. -Files containing the null character (U+0000) in the read portion are considered binary files and displayed as 'binary'. +Files containing the null character (U+0000) in the read portion are considered binary files and displayed as `binary`. - previewer string (default '') (not filtered if empty) +## previewer (string) (default ``) (not filtered if empty) Set the path of a previewer file to filter the content of regular files for previewing. The file should be executable. @@ -853,126 +845,126 @@ If the previewer returns a non-zero exit code, then the preview cache for the gi This means that if the file is selected in the future, the previewer is called once again. Preview filtering is disabled and files are displayed as they are when the value of this option is left empty. - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") +## promptfmt (string) (default `\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m`) Format string of the prompt shown in the top line. -Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen. -Home folder is shown as '~' in the working directory expansion. +Special expansions are provided, `%u` as the user name, `%h` as the host name, `%w` as the working directory, `%d` as the working directory with a trailing path separator, `%f` as the file name, and `%F` as the current filter. `%S` may be used once and will provide a spacer so that the following parts are right aligned on the screen. +Home folder is shown as `~` in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen. - ratios []int (default '1:2:3') +## ratios ([]int) (default `1:2:3`) List of ratios of pane widths. Number of items in the list determines the number of panes in the ui. -When 'preview' option is enabled, the right most number is used for the width of preview pane. +When `preview` option is enabled, the right most number is used for the width of preview pane. - relativenumber bool (default false) +## relativenumber (bool) (default false) Show the position number relative to the current line. -When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown. +When `number` is enabled, current line shows the absolute position, otherwise nothing is shown. - reverse bool (default false) +## reverse (bool) (default false) Reverse the direction of sort. - ruler []string (default 'acc:progress:selection:filter:ind') +## ruler ([]string) (default `acc:progress:selection:filter:ind`) This option is deprecated in favor of using the `rulerfmt` option (see below). List of information shown in status line ruler. -Currently supported information types are 'acc', 'progress', 'selection', 'filter', 'ind', 'df' and names starting with 'lf_'. +Currently supported information types are `acc`, `progress`, `selection`, `filter`, `ind`, `df` and names starting with `lf_`. `acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings). `progress` shows the progress of file operations (e.g. copying a large directory). `selection` shows the number of files that are selected, or designated for being cut/copied. -`filter` shows 'F' if a filter is currently being applied. +`filter` shows `F` if a filter is currently being applied. `ind` shows the current position of the cursor as well as the number of files in the current directory. `df` shows the amount of free disk space remaining. Names starting with `lf_` show the value of environment variables exported by lf. This is useful for displaying the current settings (e.g. `lf_selmode` displays the current setting for the `selmode` option). User defined options starting with `lf_user_` are also supported, so it is possible to display information set from external sources. - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") +## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t`) Format string of the ruler shown in the bottom right corner. -Special expansions are provided, '%a' as the pressed keys, '%p' as the progress of file operations, '%m' as the number of files to be cut (moved), '%c' as the number of files to be copied, '%s' as the number of selected files, '%f' as the filter, '%i' as the position of the cursor, '%t' as the number of files shown in the current directory, '%h' as the number of files hidden in the current directory, and '%d' as the amount of free disk space remaining. +Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, and `%d` as the amount of free disk space remaining. Additional expansions are provided for environment variables exported by lf, in the form `%{lf_}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings. Expansions are also provided for user defined options, in the form `%{lf_user_}` (e.g. `%{lf_user_foo}`). The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. - selmode string (default 'all') +## selmode (string) (default `all`) Selection mode for commands. -When set to 'all' it will use the selected files from all directories. -When set to 'dir' it will only use the selected files in the current directory. +When set to `all` it will use the selected files from all directories. +When set to `dir` it will only use the selected files in the current directory. - scrolloff int (default 0) +## scrolloff (int) (default 0) Minimum number of offset lines shown at all times in the top and the bottom of the screen when scrolling. The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items. - shell string (default 'sh' for Unix and 'cmd' for Windows) +## shell (string) (default `sh` for Unix and `cmd` for Windows) Shell executable to use for shell commands. -Shell commands are executed as 'shell shellopts shellflag command -- arguments'. +Shell commands are executed as `shell shellopts shellflag command -- arguments`. - shellflag string (default '-c' for Unix and '/c' for Windows) +## shellflag (string) (default `-c` for Unix and `/c` for Windows) Command line flag used to pass shell commands. - shellopts []string (default '') +## shellopts ([]string) (default ``) List of shell options to pass to the shell executable. - sixel bool (default false) +## sixel (bool) (default false) Render sixel images in preview. - smartcase bool (default true) +## smartcase (bool) (default true) -Override 'ignorecase' option when the pattern contains an uppercase character. -This option has no effect when 'ignorecase' is disabled. +Override `ignorecase` option when the pattern contains an uppercase character. +This option has no effect when `ignorecase` is disabled. - smartdia bool (default false) +## smartdia (bool) (default false) -Override 'ignoredia' option when the pattern contains a character with diacritic. -This option has no effect when 'ignoredia' is disabled. +Override `ignoredia` option when the pattern contains a character with diacritic. +This option has no effect when `ignoredia` is disabled. - sortby string (default 'natural') +## sortby (string) (default `natural`) Sort type for directories. -Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', 'atime', and 'ext'. +Currently supported sort types are `natural`, `name`, `size`, `time`, `ctime`, `atime`, and `ext`. - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") +## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`) Format string of the file info shown in the bottom left corner. -Special expansions are provided, '%p' as the file permissions, '%c' as the link count, '%u' as the user, '%g' as the group, '%s' as the file size, '%S' as the file size but with a fixed width of four characters (left-padded with spaces), '%t' as the last modified time, and '%l' as the link target. +Special expansions are provided, `%p` as the file permissions, `%c` as the link count, `%u` as the user, `%g` as the group, `%s` as the file size, `%S` as the file size but with a fixed width of four characters (left-padded with spaces), `%t` as the last modified time, and `%l` as the link target. The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. - tabstop int (default 8) +## tabstop (int) (default 8) Number of space characters to show for horizontal tabulation (U+0009) character. - tagfmt string (default "\033[31m") +## tagfmt (string) (default `\033[31m`) Format string of the tags. If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. -For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". +For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`. - tempmarks string (default '') +## tempmarks (string) (default ``) -Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c'). +Marks to be considered temporary (e.g. `abc` refers to marks `a`, `b`, and `c`). These marks are not synced to other clients and they are not saved in the bookmarks file. -Note that the special bookmark "'" is always treated as temporary and it does not need to be specified. +Note that the special bookmark `` ` `` is always treated as temporary and it does not need to be specified. - timefmt string (default 'Mon Jan _2 15:04:05 2006') +## timefmt (string) (default `Mon Jan _2 15:04:05 2006`) Format string of the file modification time shown in the bottom line. - truncatechar string (default '~') +## truncatechar (string) (default `~`) Truncate character shown at the end when the file name does not fit to the pane. - truncatepct int (default 100) +## truncatepct (int) (default 100) When a filename is too long to be shown completely, the available space is partitioned in two pieces. truncatepct defines a fraction (in percent @@ -983,143 +975,142 @@ truncation character (truncatechar). A value of 100 will only show the beginning of the filename, while a value of 0 will only show the end of the filename, e.g.: -- `set truncatepct 100` -> "very-long-filename-tr~" (default) +- `set truncatepct 100` -> `very-long-filename-tr~` (default) -- `set truncatepct 50` -> "very-long-f~-truncated" +- `set truncatepct 50` -> `very-long-f~-truncated` -- `set truncatepct 0` -> "~ng-filename-truncated" +- `set truncatepct 0` -> `~ng-filename-truncated` - waitmsg string (default 'Press any key to continue') +## waitmsg (string) (default `Press any key to continue`) String shown after commands of shell-wait type. - wrapscan bool (default true) +## wrapscan (bool) (default true) Searching can wrap around the file list. - wrapscroll bool (default false) +## wrapscroll (bool) (default false) Scrolling can wrap around the file list. - user_{option} string (default none) +## user_{option} (string) (default none) -Any option that is prefixed with 'user_' is a user defined option and can be set to any string. +Any option that is prefixed with `user_` is a user defined option and can be set to any string. Inside a user defined command the value will be provided in the `lf_user_{option}` environment variable. These options are not used by lf and are not persisted. -# Environment Variables +# ENVIRONMENT VARIABLES The following variables are exported for shell commands: -These are referred with a '$' prefix on POSIX shells (e.g. '$f'), between '%' characters on Windows cmd (e.g. '%f%'), and with a '$env:' prefix on Windows powershell (e.g. '$env:f'). +These are referred with a `$` prefix on POSIX shells (e.g. `$f`), between `%` characters on Windows cmd (e.g. `%f%`), and with a `$env:` prefix on Windows powershell (e.g. `$env:f`). - f +## f Current file selection as a full path. - fs +## fs -Selected file(s) separated with the value of 'filesep' option as full path(s). +Selected file(s) separated with the value of `filesep` option as full path(s). - fx +## fx -Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current file selection (i.e. 'f'). +Selected file(s) (i.e. `fs`) if there are any selected files, otherwise current file selection (i.e. `f`). - id +## id Id of the running client. - PWD +## PWD Present working directory. - OLDPWD +## OLDPWD Initial working directory. - LF_LEVEL +## LF_LEVEL The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf. You can add the value of this variable to your shell prompt to make it clear that your shell runs inside lf. -For example, with POSIX shells, you can use '[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc'). +For example, with POSIX shells, you can use `[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) "` in your shell configuration file (e.g. `~/.bashrc`). - OPENER +## OPENER -If this variable is set in the environment, use the same value. Otherwise, this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in MacOS, `xdg-open` in others. - EDITOR +## EDITOR -If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows. +If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to `vi` on Unix, `notepad` in Windows. - PAGER +## PAGER -If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to `less` on Unix, `more` in Windows. - SHELL +## SHELL -If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows. +If this variable is set in the environment, use the same value. Otherwise, this is set to `sh` on Unix, `cmd` in Windows. - lf +## lf -Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'. +Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string `lf`. - lf_{option} +## lf_{option} Value of the {option}. - lf_user_{option} +## lf_user_{option} Value of the user_{option}. - lf_width - lf_height +## lf_width, lf_height Width/Height of the terminal. - lf_count +## lf_count Value of the count associated with the current command. -# Special Commands +# SPECIAL COMMANDS This section shows information about special shell commands. - open +## open -This shell command can be defined to override the default 'open' command when the current file is not a directory. +This shell command can be defined to override the default `open` command when the current file is not a directory. - paste +## paste -This shell command can be defined to override the default 'paste' command. +This shell command can be defined to override the default `paste` command. - rename +## rename -This shell command can be defined to override the default 'rename' command. +This shell command can be defined to override the default `rename` command. - delete +## delete -This shell command can be defined to override the default 'delete' command. +This shell command can be defined to override the default `delete` command. - pre-cd +## pre-cd This shell command can be defined to be executed before changing a directory. - on-cd +## on-cd This shell command can be defined to be executed after changing a directory. - on-select +## on-select This shell command can be defined to be executed after the selection changes. - on-redraw +## on-redraw This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized. - on-quit +## on-quit This shell command can be defined to be executed before quit. -# Prefixes +# PREFIXES The following command prefixes are used by lf: @@ -1134,15 +1125,15 @@ The difference is that prefixes are not necessary in the command line. Instead, different modes are provided to read corresponding commands. These modes are mapped to the prefix keys above by default. -# Syntax +# SYNTAX -Characters from '#' to newline are comments and ignored: +Characters from `#` to newline are comments and ignored: - # comments start with '#' + # comments start with `#` -There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') for configuration. +There are five special commands (`set`, `setlocal`, `map`, `cmap`, and `cmd`) for configuration. -Command 'set' is used to set an option which can be boolean, integer, or string: +Command `set` is used to set an option which can be boolean, integer, or string: set hidden # boolean enable set hidden true # boolean enable @@ -1154,9 +1145,9 @@ Command 'set' is used to set an option which can be boolean, integer, or string: set sortby 'time' # string value with single quotes (whitespaces) set sortby "time" # string value with double quotes (backslash escapes) -Command 'setlocal' is used to set a local option for a directory which can be boolean or string. -Currently supported local options are 'dirfirst', 'dironly', 'hidden', 'info', 'reverse', and 'sortby'. -Adding a trailing path separator (i.e. '/' for Unix and '\' for Windows) sets the option for the given directory along with its subdirectories: +Command `setlocal` is used to set a local option for a directory which can be boolean or string. +Currently supported local options are `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, and `sortby`. +Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories: setlocal /foo/bar hidden # boolean enable setlocal /foo/bar hidden true # boolean enable @@ -1186,7 +1177,7 @@ You can delete an existing binding by leaving the expression empty: map gh # deletes 'gh' mapping cmap # deletes '' mapping -Command 'cmd' is used to define a custom command: +Command `cmd` is used to define a custom command: cmd usage $du -h -d1 | less @@ -1194,22 +1185,22 @@ You can delete an existing command by leaving the expression empty: cmd trash # deletes 'trash' command -If there is no prefix then ':' is assumed: +If there is no prefix then `:` is assumed: map zt set info time -An explicit ':' can be provided to group statements until a newline which is especially useful for 'map' and 'cmd' commands: +An explicit `:` can be provided to group statements until a newline which is especially useful for `map` and `cmd` commands: map st :set sortby time; set info time -If you need multiline you can wrap statements in '{{' and '}}' after the proper prefix. +If you need multiline you can wrap statements in `{{` and `}}` after the proper prefix. map st :{{ set sortby time set info time }} -# Key Mappings +# KEY MAPPINGS Regular keys are assigned to a command with the usual syntax: @@ -1219,7 +1210,7 @@ Keys combined with the shift key simply use the uppercase letter: map A down -Special keys are written in between '<' and '>' characters and always use lowercase letters: +Special keys are written in between `<` and `>` characters and always use lowercase letters: map down @@ -1228,11 +1219,11 @@ Angle brackets can be assigned with their special names: map down map down -Function keys are prefixed with 'f' character: +Function keys are prefixed with `f` character: map down -Keys combined with the control key are prefixed with 'c' character: +Keys combined with the control key are prefixed with `c` character: map down @@ -1244,7 +1235,7 @@ On these terminals, you can use the corresponding byte for the mapping: Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed. lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms). -On these terminals, keys combined with the alt key are prefixed with 'a' character: +On these terminals, keys combined with the alt key are prefixed with `a` character: map down @@ -1254,9 +1245,9 @@ It is possible to combine special keys with modifiers: WARNING: Some key combinations will likely be intercepted by your OS, window manager, or terminal. Other key combinations cannot be recognized by lf due to the way terminals work (e.g. `Ctrl+h` combination sends a backspace key instead). -The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the "unknown mapping" error. +The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the `unknown mapping` error. -Mouse buttons are prefixed with 'm' character: +Mouse buttons are prefixed with `m` character: map down # primary map down # secondary @@ -1267,20 +1258,20 @@ Mouse buttons are prefixed with 'm' character: map down map down -Mouse wheel events are also prefixed with 'm' character: +Mouse wheel events are also prefixed with `m` character: map down map down map down map down -# Push Mappings +# PUSH MAPPINGS The usual way to map a key sequence is to assign it to a named or unnamed command. While this provides a clean way to remap builtin keys as well as other commands, it can be limiting at times. -For this reason 'push' command is provided by lf. +For this reason `push` command is provided by lf. This command is used to simulate key pushes given as its arguments. -You can 'map' a key to a 'push' command with an argument to create various keybindings. +You can `map` a key to a `push` command with an argument to create various keybindings. This is mainly useful for two purposes. First, it can be used to map a command with a command count: @@ -1291,13 +1282,13 @@ Second, it can be used to avoid typing the name when a command takes arguments: map r push :rename -One thing to be careful is that since 'push' command works with keys instead of commands it is possible to accidentally create recursive bindings: +One thing to be careful is that since `push` command works with keys instead of commands it is possible to accidentally create recursive bindings: map j push 2j These types of bindings create a deadlock when executed. -# Shell Commands +# SHELL COMMANDS Regular shell commands are the most basic command type that is useful for many purposes. For example, we can write a shell command to move selected file(s) to trash. @@ -1312,9 +1303,9 @@ A first attempt to write such a command may look like this: fi }} -We check '$fs' to see if there are any selected files. +We check `$fs` to see if there are any selected files. Otherwise we just delete the current file. -Since this is such a common pattern, a separate '$fx' variable is provided. +Since this is such a common pattern, a separate `$fx` variable is provided. We can use this variable to get rid of the conditional: cmd trash ${{ @@ -1329,19 +1320,19 @@ We can move it outside of the command so it would only run once at startup: cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} -Since these are one liners, we can drop '{{' and '}}': +Since these are one liners, we can drop `{{` and `}}`: $mkdir -p ~/.trash cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.trash -Finally note that we set 'IFS' variable manually in these commands. -Instead we could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs "\n"'). -This can be especially useful for interactive use (e.g. '$rm $f' or '$rm $fs' would simply work). +Finally note that we set `IFS` variable manually in these commands. +Instead we could use the `ifs` option to set it for all shell commands (i.e. `set ifs "\n"`). +This can be especially useful for interactive use (e.g. `$rm $f` or `$rm $fs` would simply work). This option is not set by default as it can behave unexpectedly for new users. However, use of this option is highly recommended and it is assumed in the rest of the documentation. -# Piping Shell Commands +# PIPING SHELL COMMANDS Regular shell commands have some limitations in some cases. When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. @@ -1362,18 +1353,18 @@ For example, an alternative rename command may look like this: Note that input is line buffered and output and error are byte buffered. -# Waiting Shell Commands +# WAITING SHELL COMMANDS Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. These can be useful to see the output of a program before the ui is resumed. Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline. -# Asynchronous Shell Commands +# ASYNCHRONOUS SHELL COMMANDS Asynchronous shell commands are used to start a command in the background and then resume operation without waiting for the command to finish. Stdin, stdout, and stderr of the command is neither connected to the terminal nor to the ui. -# Remote Commands +# REMOTE COMMANDS One of the more advanced features in lf is remote commands. All clients connect to a server on startup. @@ -1392,13 +1383,13 @@ This is the recommended way of using remote commands since it is shorter and imm lf -remote 'send echo hello world' -In this command 'send' is used to send the rest of the string as a command to all connected clients. +In this command `send` is used to send the rest of the string as a command to all connected clients. You can optionally give it an id number to send a command to a single client: lf -remote 'send 1234 echo hello world' All clients have a unique id number but you may not be aware of the id number when you are writing a command. -For this purpose, an '$id' variable is exported to the environment for shell commands. +For this purpose, an `$id` variable is exported to the environment for shell commands. The value of this variable is set to the process id of the client. You can use it to send a remote command from a client to the server which in return sends a command back to itself. So now you can display a message in the current client by calling the following in a shell command: @@ -1418,7 +1409,7 @@ For example, you can configure the number of columns in the ui with respect to t fi }} -In addition, the 'query' command can be used to obtain information about a specific lf instance by providing its id: +In addition, the `query` command can be used to obtain information about a specific lf instance by providing its id: lf -remote "query $id maps" @@ -1444,20 +1435,20 @@ For example, to select a previous command using fzf and execute it: lf -remote "send $id $cmd" }} -There is also a 'quit' command to quit the server when there are no connected clients left, and a 'quit!' command to force quit the server by closing client connections first: +There is also a `quit` command to quit the server when there are no connected clients left, and a `quit!` command to force quit the server by closing client connections first: lf -remote 'quit' lf -remote 'quit!' -Lastly, there is a 'conn' command to connect the server as a client. +Lastly, there is a `conn` command to connect the server as a client. This should not be needed for users. -# File Operations +# FILE OPERATIONS lf uses its own builtin copy and move operations by default. These are implemented as asynchronous operations and progress is shown in the bottom ruler. These commands do not overwrite existing files or directories with the same name. -Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories. +Instead, a suffix that is compatible with `--backup=numbered` option in GNU cp is added to the new files or directories. Only file modes and (some) timestamps can be preserved (see `preserve` option), all other attributes are ignored including ownership, context, and xattr. Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed. Moving is performed using the rename operation of the underlying OS. @@ -1465,11 +1456,11 @@ For cross-device moving, lf falls back to copying and then deletes the original Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation. File operations can be performed on the current selected file or alternatively on multiple files by selecting them first. -When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to a file. -The actual file copying takes place when you 'paste'. -Similarly 'paste' after a 'cut' operation moves the file. +When you `copy` a file, lf doesn't actually copy the file on the disk, but only records its name to a file. +The actual file copying takes place when you `paste`. +Similarly `paste` after a `cut` operation moves the file. -You can customize copy and move operations by defining a 'paste' command. +You can customize copy and move operations by defining a `paste` command. This is a special command that is called when it is defined instead of the builtin implementation. You can use the following example as a starting point: @@ -1486,45 +1477,45 @@ You can use the following example as a starting point: fi }} -Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls. +Some useful things to be considered are to use the backup (`--backup`) and/or preserve attributes (`-a`) options with `cp` and `mv` commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use `rsync` command with progress bar option for copying and feed the progress to the client periodically with remote `echo` calls. -By default, lf does not assign 'delete' command to a key to protect new users. -You can customize file deletion by defining a 'delete' command. +By default, lf does not assign `delete` command to a key to protect new users. +You can customize file deletion by defining a `delete` command. You can also assign a key to this command if you like. An example command to move selected files to a trash folder and remove files completely after a prompt are provided in the example configuration file. -# Searching Files +# SEARCHING FILES There are two mechanisms implemented in lf to search a file in the current directory. Searching is the traditional method to move the selection to a file matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes. -Searching mechanism is implemented with commands 'search' (default '/'), 'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' (default 'N'). -You can enable 'globsearch' option to match with a glob pattern. -Globbing supports '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. -You can enable 'incsearch' option to jump to the current match at each keystroke while typing. -In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' to cancel the search. -You can also map some other commands with 'cmap' to accept the search and execute the command immediately afterwards. +Searching mechanism is implemented with commands `search` (default `/`), `search-back` (default `?`), `search-next` (default `n`), and `search-prev` (default `N`). +You can enable `globsearch` option to match with a glob pattern. +Globbing supports `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges. +You can enable `incsearch` option to jump to the current match at each keystroke while typing. +In this mode, you can either use `cmd-enter` to accept the search or use `cmd-escape` to cancel the search. +You can also map some other commands with `cmap` to accept the search and execute the command immediately afterwards. For example, you can use the right arrow key to finish the search and open the selected file with the following mapping: cmap :cmd-enter; open -Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default ','). -You can disable 'anchorfind' option to match a pattern at an arbitrary position in the filename instead of the beginning. -You can set the number of keys to match using 'findlen' option. +Finding mechanism is implemented with commands `find` (default `f`), `find-back` (default `F`), `find-next` (default `;`), `find-prev` (default `,`). +You can disable `anchorfind` option to match a pattern at an arbitrary position in the filename instead of the beginning. +You can set the number of keys to match using `findlen` option. If you set this value to zero, then the the keys are read until there is only a single match. Default values of these two options are set to jump to the first file with the given initial. Some options effect both searching and finding. -You can disable 'wrapscan' option to prevent searches to wrap around at the end of the file list. -You can disable 'ignorecase' option to match cases in the pattern and the filename. +You can disable `wrapscan` option to prevent searches to wrap around at the end of the file list. +You can disable `ignorecase` option to match cases in the pattern and the filename. This option is already automatically overridden if the pattern contains upper case characters. -You can disable 'smartcase' option to disable this behavior. -Two similar options 'ignoredia' and 'smartdia' are provided to control matching diacritics in latin letters. +You can disable `smartcase` option to disable this behavior. +Two similar options `ignoredia` and `smartdia` are provided to control matching diacritics in latin letters. -# Opening Files +# OPENING FILES -You can define a an 'open' command (default 'l' and '') to configure file opening. +You can define a an `open` command (default `l` and ``) to configure file opening. This command is only called when the current file is not a directory, otherwise the directory is entered instead. You can define it just as you would define any other command: @@ -1534,7 +1525,7 @@ It is possible to use different command types: cmd open &xdg-open $f -You may want to use either file extensions or mime types from 'file' command: +You may want to use either file extensions or mime types from `file` command: cmd open ${{ case $(file --mime-type -Lb $f) in @@ -1543,10 +1534,10 @@ You may want to use either file extensions or mime types from 'file' command: esac }} -You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits. +You may want to use `setsid` before your opener command to have persistent processes that continue to run after lf quits. -Regular shell commands (i.e. '$') drop to terminal which results in a flicker for commands that finishes immediately (e.g. 'xdg-open' in the above example). -If you want to use asynchronous shell commands (i.e. '&') but also want to use the terminal when necessary (e.g. 'vi' in the above exxample), you can use a remote command: +Regular shell commands (i.e. `$`) drop to terminal which results in a flicker for commands that finishes immediately (e.g. `xdg-open` in the above example). +If you want to use asynchronous shell commands (i.e. `&`) but also want to use the terminal when necessary (e.g. `vi` in the above exxample), you can use a remote command: cmd open &{{ case $(file --mime-type -Lb $f) in @@ -1555,23 +1546,23 @@ If you want to use asynchronous shell commands (i.e. '&') but also want to use t esac }} -Note, asynchronous shell commands run in their own process group by default so they do not require the manual use of 'setsid'. +Note, asynchronous shell commands run in their own process group by default so they do not require the manual use of `setsid`. Following command is provided by default: cmd open &$OPENER $f You may also use any other existing file openers as you like. -Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or 'mimeo' to name a few. +Possible options are `libfile-mimeinfo-perl` (executable name is `mimeopen`), `rifle` (ranger's default file opener), or `mimeo` to name a few. -# Previewing Files +# PREVIEWING FILES lf previews files on the preview pane by printing the file until the end or the preview pane is filled. This output can be enhanced by providing a custom preview script for filtering. This can be used to highlight source codes, list contents of archive files or view pdf or image files to name a few. For coloring lf recognizes ansi escape codes. -In order to use this feature you need to set the value of 'previewer' option to the path of an executable file. +In order 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 file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. 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: @@ -1579,13 +1570,13 @@ You may also want to use the same script in your pager mapping as well: set previewer ~/.config/lf/pv.sh 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: +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. +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 @@ -1600,29 +1591,29 @@ Extensions can then be used to match cleanly within a conditional: esac Another important consideration for efficiency is the use of programs with short startup times for preview. -For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. +For this reason, `highlight` is recommended over `pygmentize` for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do 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 You may also use an existing preview filter as you like. -Your system may already come with a preview filter named 'lesspipe'. +Your system may already come with a preview filter named `lesspipe`. These filters may have a mechanism to add user customizations as well. See the related documentations for more information. -# Changing Directory +# CHANGING DIRECTORY lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository at https://github.com/gokcehan/lf/tree/master/etc -There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed. +There is a special command `on-cd` that runs a shell command when it is defined and the directory is changed. You can define it just as you would define any other command: cmd on-cd &{{ @@ -1639,7 +1630,7 @@ You can define it just as you would define any other command: ' }} -If you want to print escape sequences, you may redirect 'printf' output to '/dev/tty'. +If you want to print escape sequences, you may redirect `printf` output to `/dev/tty`. The following xterm specific escape sequence sets the terminal title to the working directory: cmd on-cd &{{ @@ -1652,11 +1643,11 @@ You can add an extra call to make it run on startup as well: cmd on-cd &{{ ... }} on-cd -Note that all shell commands are possible but '%' and '&' are usually more appropriate as '$' and '!' causes flickers and pauses respectively. +Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively. -There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed. +There is also a `pre-cd` command, that works like `on-cd`, but is run before the directory is actually changed. -# Colors +# COLORS lf tries to automatically adapt its colors to the environment. It starts with a default colorscheme and updates colors using values of existing environment variables possibly by overwriting its previous values. @@ -1668,11 +1659,11 @@ Colors are set in the following order: 4. LF_COLORS (lf specific) 5. colors file (lf specific) -Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'. -'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls. +Please refer to the corresponding man pages for more information about `LSCOLORS` and `LS_COLORS`. +`LF_COLORS` is provided with the same syntax as `LS_COLORS` in case you want to configure colors only for lf but not ls. This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases. Colors file is provided for easier configuration without environment variables. -This file should consist of whitespace separated pairs with '#' character to start comments until the end of line. +This file should consist of whitespace separated pairs with `#` character to start comments until the end of line. You can configure lf colors in two different ways. First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically. @@ -1680,16 +1671,16 @@ Depending on your terminal, you should be able to select your colors from a 24-b This is the recommended approach as colors used by other programs will also match each other. Second, you can set the values of environment variables or colors file mentioned above for fine grained customization. -Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system. +Note that `LS_COLORS/LF_COLORS` are more powerful than `LSCOLORS` and they can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results. Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. -Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes. +Colors of the prompt line can be configured using the `promptfmt` option which can include hardcoded colors as ansi escapes. See the default value of this option to have an idea about how to color this line. It is worth noting that lf uses as many colors advertised by your terminal's entry in terminfo or infocmp databases on your system. If an entry is not present, it falls back to an internal database. -If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the '$COLORTERM' variable to 'truecolor' or ensuring '$TERM' is set to a value that ends with '-truecolor'. +If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the `$COLORTERM` variable to `truecolor` or ensuring `$TERM` is set to a value that ends with `-truecolor`. Default lf colors are mostly taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute. @@ -1715,36 +1706,36 @@ Default values are as follows given with their matching order in lf: Note that lf first tries matching file names and then falls back to file types. The full order of matchings from most specific to least are as follows: - 1. Full Path (e.g. '~/.config/lf/lfrc') - 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Type (e.g. 'ln') (except 'fi') - 4. File Name (e.g. 'README*') - 5. File Name (e.g. '*README') - 6. Base Name (e.g. 'README.*') - 7. Extension (e.g. '*.txt') - 8. Default (i.e. 'fi') + 1. Full Path (e.g. `~/.config/lf/lfrc`) + 2. Dir Name (e.g. `.git/`) (only matches dirs with a trailing slash at the end) + 3. File Type (e.g. `ln`) (except `fi`) + 4. File Name (e.g. `README*`) + 5. File Name (e.g. `*README`) + 6. Base Name (e.g. `README.*`) + 7. Extension (e.g. `*.txt`) + 8. Default (i.e. `fi`) -For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used: +For example, given a regular text file `/path/to/README.txt`, the following entries are checked in the configuration and the first one to match is used: - 1. '/path/to/README.txt' + 1. `/path/to/README.txt` 2. (skipped since the file is not a directory) - 3. (skipped since the file is of type 'fi') - 4. 'README.txt*' - 5. '*README.txt' - 6. 'README.*' - 7. '*.txt' - 8. 'fi' + 3. (skipped since the file is of type `fi`) + 4. `README.txt*` + 5. `*README.txt` + 6. `README.*` + 7. `*.txt` + 8. `fi` -Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used: +Given a regular directory `/path/to/example.d`, the following entries are checked in the configuration and the first one to match is used: - 1. '/path/to/example.d' - 2. 'example.d/' - 3. 'di' - 4. 'example.d*' - 5. '*example.d' - 6. 'example.*' - 7. '*.d' - 8. 'fi' + 1. `/path/to/example.d` + 2. `example.d/` + 3. `di` + 4. `example.d*` + 5. `*example.d` + 6. `example.*` + 7. `*.d` + 8. `fi` Note that glob-like patterns do not actually perform glob matching due to performance reasons. @@ -1779,13 +1770,13 @@ https://github.com/gokcehan/lf/blob/master/etc/colors.example You may also see the wiki page for ansi escape codes https://en.wikipedia.org/wiki/ANSI_escape_code -# Icons +# ICONS -Icons are configured using 'LF_ICONS' environment variable or an icons file. -The variable uses the same syntax as 'LS_COLORS/LF_COLORS'. +Icons are configured using `LF_ICONS` environment variable or an icons file. +The variable uses the same syntax as `LS_COLORS/LF_COLORS`. Instead of colors, you should put a single characters as values of entries. -Icons file should consist of whitespace separated pairs with '#' character to start comments until the end of line. -Do not forget to enable 'icons' option to see the icons. +Icons file should consist of whitespace separated pairs with `#` character to start comments until the end of line. +Do not forget to enable `icons` option to see the icons. Default values are as follows given with their matching order in lf: ln l @@ -1805,5 +1796,3 @@ Default values are as follows given with their matching order in lf: A sample icons file can be found at https://github.com/gokcehan/lf/blob/master/etc/icons.example -*/ -package main diff --git a/doc.txt b/doc.txt new file mode 100644 index 00000000..76a0cfda --- /dev/null +++ b/doc.txt @@ -0,0 +1,2258 @@ + + +NAME + + +lf - terminal file manager + + + +SYNOPSIS + + +LF [-COMMAND _command_] [-CONFIG _path_] [-CPUPROFILE _path_] [-DOC] +[-LAST-DIR-PATH _path_] [-LOG PATH] [-MEMPROFILE _path_] +[-PRINT-LAST-DIR] [-PRINT-SELECTION] [-REMOTE _command_] +[-SELECTION-PATH _path_] [-SERVER] [-SINGLE] [-VERSION] [-HELP] +[_cd-or-select-path_] + + + +DESCRIPTION + + +lf is a terminal file manager. + +Source code can be found in the repository at +https://github.com/gokcehan/lf + +This documentation can either be read from terminal using lf -doc or +online at https://github.com/gokcehan/lf/blob/master/doc.md You can also +use doc command (default ) inside lf to view the documentation in a +pager. A man page with the same content is also available in the +repository at https://github.com/gokcehan/lf/blob/master/lf.1 + +You can run lf -help to see descriptions of command line options. + + + +QUICK REFERENCE + + +The following commands are provided by lf: + + quit (default 'q') + up (default 'k' and '') + half-up (default '') + page-up (default '' and '') + scroll-up (default '') + down (default 'j' and '') + half-down (default '') + page-down (default '' and '') + scroll-down (default '') + updir (default 'h' and '') + open (default 'l' and '') + jump-next (default ']') + jump-prev (default '[') + top (default 'gg' and '') + bottom (default 'G' and '') + high (default 'H') + middle (default 'M') + low (default 'L') + toggle + invert (default 'v') + invert-below + unselect (default 'u') + glob-select + glob-unselect + calcdirsize + clearmaps + copy (default 'y') + cut (default 'd') + paste (default 'p') + clear (default 'c') + sync + draw + redraw (default '') + load + reload (default '') + echo + echomsg + echoerr + cd + select + delete (modal) + rename (modal) (default 'r') + source + push + read (modal) (default ':') + shell (modal) (default '$') + shell-pipe (modal) (default '%') + shell-wait (modal) (default '!') + shell-async (modal) (default '&') + find (modal) (default 'f') + find-back (modal) (default 'F') + find-next (default ';') + find-prev (default ',') + search (modal) (default '/') + search-back (modal) (default '?') + search-next (default 'n') + search-prev (default 'N') + filter (modal) + setfilter + mark-save (modal) (default 'm') + mark-load (modal) (default "'") + mark-remove (modal) (default '"') + tag + tag-toggle (default 't') + +The following command line commands are provided by lf: + + cmd-escape (default '') + cmd-complete (default '') + cmd-menu-complete + cmd-menu-complete-back + cmd-menu-accept + cmd-enter (default '' and '') + cmd-interrupt (default '') + cmd-history-next (default '' and '') + cmd-history-prev (default '' and '') + cmd-left (default '' and '') + cmd-right (default '' and '') + cmd-home (default '' and '') + cmd-end (default '' and '') + cmd-delete (default '' and '') + cmd-delete-back (default '' and '') + cmd-delete-home (default '') + cmd-delete-end (default '') + cmd-delete-unix-word (default '') + cmd-yank (default '') + cmd-transpose (default '') + cmd-transpose-word (default '') + cmd-word (default '') + cmd-word-back (default '') + cmd-delete-word (default '') + cmd-delete-word-back (default '' and '') + cmd-capitalize-word (default '') + cmd-uppercase-word (default '') + cmd-lowercase-word (default '') + +The following options can be used to customize the behavior of lf: + + anchorfind bool (default true) + autoquit bool (default false) + borderfmt string (default "\033[0m") + cleaner string (default '') + cursoractivefmt string (default "\033[7m") + cursorparentfmt string (default "\033[7m") + cursorpreviewfmt string (default "\033[4m") + dircache bool (default true) + dircounts bool (default false) + dirfirst bool (default true) + dironly bool (default false) + dirpreviews bool (default false) + drawbox bool (default false) + dupfilefmt string (default '%f.~%n~') + errorfmt string (default "\033[7;31;47m") + filesep string (default "\n") + findlen int (default 1) + globsearch bool (default false) + hidden bool (default false) + hiddenfiles []string (default '.*') + history bool (default true) + icons bool (default false) + ifs string (default '') + ignorecase bool (default true) + ignoredia bool (default true) + incfilter bool (default false) + incsearch bool (default false) + info []string (default '') + infotimefmtnew string (default 'Jan _2 15:04') + infotimefmtold string (default 'Jan _2 2006') + mouse bool (default false) + number bool (default false) + numberfmt string (default "\033[33m") + period int (default 0) + preserve []string (default "mode") + preview bool (default true) + previewer string (default '') + promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") + ratios []int (default '1:2:3') + relativenumber bool (default false) + reverse bool (default false) + ruler []string (default 'acc:progress:selection:filter:ind') + rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") + scrolloff int (default 0) + selmode string (default 'all') + shell string (default 'sh' for Unix and 'cmd' for Windows) + shellflag string (default '-c' for Unix and '/c' for Windows) + shellopts []string (default '') + sixel bool (default false) + smartcase bool (default true) + smartdia bool (default false) + sortby string (default 'natural') + statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") + tabstop int (default 8) + tagfmt string (default "\033[31m") + tempmarks string (default '') + timefmt string (default 'Mon Jan _2 15:04:05 2006') + truncatechar string (default '~') + truncatepct int (default 100) + waitmsg string (default 'Press any key to continue') + wrapscan bool (default true) + wrapscroll bool (default false) + user_{option} string (default none) + +The following environment variables are exported for shell commands: + + f + fs + fx + id + PWD + OLDPWD + LF_LEVEL + OPENER + VISUAL + EDITOR + PAGER + SHELL + lf + lf_{option} + lf_user_{option} + lf_width + lf_height + lf_count + +The following special shell commands are used to customize the behavior +of lf when defined: + + open + paste + rename + delete + pre-cd + on-cd + on-select + on-redraw + on-quit + +The following commands/keybindings are provided by default: + + Unix + cmd open &$OPENER "$f" + map e $$EDITOR "$f" + map i $$PAGER "$f" + map w $$SHELL + cmd doc $$lf -doc | $PAGER + map doc + cmd maps $lf -remote "query $id maps" | $PAGER + cmd cmaps $lf -remote "query $id cmaps" | $PAGER + cmd cmds $lf -remote "query $id cmds" | $PAGER + + Windows + cmd open &%OPENER% %f% + map e $%EDITOR% %f% + map i !%PAGER% %f% + map w $%SHELL% + cmd doc !%lf% -doc | %PAGER% + map doc + cmd maps !%lf% -remote "query %id% maps" | %PAGER% + cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER% + cmd cmds !%lf% -remote "query %id% cmds" | %PAGER% + +The following additional keybindings are provided by default: + + map zh set hidden! + map zr set reverse! + map zn set info + map zs set info size + map zt set info time + map za set info size:time + map sn :set sortby natural; set info + map ss :set sortby size; set info size + map st :set sortby time; set info time + map sa :set sortby atime; set info atime + map sc :set sortby ctime; set info ctime + map se :set sortby ext; set info + map gh cd ~ + map :toggle; down + +If the mouse option is enabled, mouse buttons have the following default +effects: + + Left mouse button + Click on a file or directory to select it. + + Right mouse button + Enter a directory or open a file. Also works on the preview window. + + Scroll wheel + Move up or down. If Ctrl is pressed, scroll up or down. + + + +CONFIGURATION + + +Configuration files should be located at: + + OS system-wide user-specific + Unix /etc/lf/lfrc ~/.config/lf/lfrc + Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Local\lf\lfrc + +Colors file should be located at: + + OS system-wide user-specific + Unix /etc/lf/colors ~/.config/lf/colors + Windows C:\ProgramData\lf\colors C:\Users\\AppData\Local\lf\colors + +Icons file should be located at: + + OS system-wide user-specific + Unix /etc/lf/icons ~/.config/lf/icons + Windows C:\ProgramData\lf\icons C:\Users\\AppData\Local\lf\icons + +Selection file should be located at: + + Unix ~/.local/share/lf/files + Windows C:\Users\\AppData\Local\lf\files + +Marks file should be located at: + + Unix ~/.local/share/lf/marks + Windows C:\Users\\AppData\Local\lf\marks + +Tags file should be located at: + + Unix ~/.local/share/lf/tags + Windows C:\Users\\AppData\Local\lf\tags + +History file should be located at: + + Unix ~/.local/share/lf/history + Windows C:\Users\\AppData\Local\lf\history + +You can configure these locations with the following variables given +with their order of precedences and their default values: + + Unix + $LF_CONFIG_HOME + $XDG_CONFIG_HOME + ~/.config + + $LF_DATA_HOME + $XDG_DATA_HOME + ~/.local/share + + Windows + %ProgramData% + C:\ProgramData + + %LF_CONFIG_HOME% + %LOCALAPPDATA% + C:\Users\\AppData\Local + +A sample configuration file can be found at +https://github.com/gokcehan/lf/blob/master/etc/lfrc.example + + + +COMMANDS + + +This section shows information about builtin commands. Modal commands do +not take any arguments, but instead change the operation mode to read +their input conveniently, and so they are meant to be assigned to +keybindings. + + +quit (default q) + +Quit lf and return to the shell. + + +up (default k and ), half-up (default ), page-up (default and ), scroll-up (default ), down (default j and ), half-down (default ), page-down (default and ), scroll-down (default ) + +Move/scroll the current file selection upwards/downwards by one/half a +page/full page. + + +updir (default h and ) + +Change the current working directory to the parent directory. + + +open (default l and ) + +If the current file is a directory, then change the current directory to +it, otherwise, execute the open command. A default open command is +provided to call the default system opener asynchronously with the +current file as the argument. A custom open command can be defined to +override this default. + + +jump-next (default ]), jump-prev (default [) + +Change the current working directory to the next/previous jumplist item. + + +top (default gg and ), bottom (default G and ) + +Move the current file selection to the top/bottom of the directory. A +count can be specified to move to a specific line, for example use 3G to +move to the third line. + + +high (default H), middle (default M), low (default L) + +Move the current file selection to the high/middle/low of the screen. + + +toggle + +Toggle the selection of the current file or files given as arguments. + + +invert (default v) + +Reverse the selection of all files in the current directory (i.e. toggle +all files). Selections in other directories are not effected by this +command. You can define a new command to select all files in the +directory by combining invert with unselect (i.e. +cmd select-all :unselect; invert), though this will also remove +selections in other directories. + + +invert-below + +Reverse the selection (i.e. toggle) of all files at or after the current +file in the current directory. + +To select a contiguous block of files, use this command on the first +file you want to select. Then, move down to the first file you do _not_ +want to select (the one after the end of the desired selection) and use +this command again. This achieves an effect similar to the visual mode +in vim. + +This command is experimental and may be removed once a better +replacement for the visual mode is implemented in lf. If you'd like to +experiment with using this command, you should bind it to a key (e.g. V) +for a better experience. + + +unselect (default u) + +Remove the selection of all files in all directories. + + +glob-select, glob-unselect + +Select/unselect files that match the given glob. + + +calcdirsize + +Calculate the total size for each of the selected directories. Option +info should include size and option dircounts should be disabled to show +this size. If the total size of a directory is not calculated, it will +be shown as -. + + +clearmaps + +Remove all keybindings associated with the map command. This command can +be used in the config file to remove the default keybindings. For safety +purposes, : is left mapped to the read command, and cmap keybindings are +retained so that it is still possible to exit lf using :quit. + + +copy (default y) + +If there are no selections, save the path of the current file to the +copy buffer, otherwise, copy the paths of selected files. + + +cut (default d) + +If there are no selections, save the path of the current file to the cut +buffer, otherwise, copy the paths of selected files. + + +paste (default p) + +Copy/Move files in copy/cut buffer to the current working directory. A +custom paste command can be defined to override this default. + + +clear (default c) + +Clear file paths in copy/cut buffer. + + +sync + +Synchronize copied/cut files with server. This command is automatically +called when required. + + +draw + +Draw the screen. This command is automatically called when required. + + +redraw (default ) + +Synchronize the terminal and redraw the screen. + + +load + +Load modified files and directories. This command is automatically +called when required. + + +reload (default ) + +Flush the cache and reload all files and directories. + + +echo + +Print given arguments to the message line at the bottom. + + +echomsg + +Print given arguments to the message line at the bottom and also to the +log file. + + +echoerr + +Print given arguments to the message line at the bottom as errorfmt and +also to the log file. + + +cd + +Change the working directory to the given argument. + + +select + +Change the current file selection to the given argument. + + +delete (modal) + +Remove the current file or selected file(s). A custom delete command can +be defined to override this default. + + +rename (modal) (default r) + +Rename the current file using the builtin method. A custom rename +command can be defined to override this default. + + +source + +Read the configuration file given in the argument. + + +push + +Simulate key pushes given in the argument. + + +read (modal) (default :) + +Read a command to evaluate. + + +shell (modal) (default $) + +Read a shell command to execute. + + +shell-pipe (modal) (default %) + +Read a shell command to execute piping its standard I/O to the bottom +statline. + + +shell-wait (modal) (default !) + +Read a shell command to execute and wait for a key press in the end. + + +shell-async (modal) (default &) + +Read a shell command to execute asynchronously without standard I/O. + + +find (modal) (default f), find-back (modal) (default F), find-next (default ;), find-prev (default ,) + +Read key(s) to find the appropriate file name match in the +forward/backward direction and jump to the next/previous match. + + +search (default /), search-back (default ?), search-next (default n), search-prev (default N) + +Read a pattern to search for a file name match in the forward/backward +direction and jump to the next/previous match. + + +filter (modal), setfilter + +Command filter reads a pattern to filter out and only view files +matching the pattern. Command setfilter does the same but uses an +argument to set the filter immediately. You can supply an argument to +filter, in order to use that as the starting prompt. + + +mark-save (modal) (default m) + +Save the current directory as a bookmark assigned to the given key. + + +mark-load (modal) (default ') + +Change the current directory to the bookmark assigned to the given key. +A special bookmark ' holds the previous directory after a mark-load, cd, +or select command. + + +mark-remove (modal) (default ") + +Remove a bookmark assigned to the given key. + + +tag + +Tag a file with * or a single width character given in the argument. You +can define a new tag clearing command by combining tag with tag-toggle +(i.e. cmd tag-clear :tag; tag-toggle). + + +tag-toggle (default t) + +Tag a file with * or a single width character given in the argument if +the file is untagged, otherwise remove the tag. + + + +COMMAND LINE COMMANDS + + +The prompt character specifies which of the several command-line modes +you are in. For example, the read command takes you to the : mode. + +When the cursor is at the first character in : mode, pressing one of the +keys !, $, %, or & takes you to the corresponding mode. You can go back +with cmd-delete-back ( by default). + +The command line commands should be mostly compatible with readline +keybindings. A character refers to a unicode code point, a word consists +of letters and digits, and a unix word consists of any non-blank +characters. + + +cmd-escape (default ) + +Quit command line mode and return to normal mode. + + +cmd-complete (default ) + +Autocomplete the current word. + + +cmd-menu-complete, cmd-menu-complete-back + +Autocomplete the current word with menu selection. You need to assign +keys to these commands (e.g. +cmap cmd-menu-complete; cmap cmd-menu-complete-back). +You can use the assigned keys assigned to display the menu and then +cycle through completion options. + + +cmd-menu-accept + +Accept the currently selected match in menu completion and close the +menu. + + +cmd-enter (default and ) + +Execute the current line. + + +cmd-interrupt (default ) + +Interrupt the current shell-pipe command and return to the normal mode. + + +cmd-history-next (default and ), cmd-history-prev (default and ) + +Go to next/previous item in the history. + + +cmd-left (default and ), cmd-right (default and ) + +Move the cursor to the left/right. + + +cmd-home (default and ), cmd-end (default and ) + +Move the cursor to the beginning/end of line. + + +cmd-delete (default and ) + +Delete the next character. + + +cmd-delete-back (default and ) + +Delete the previous character. When at the beginning of a prompt, +returns either to normal mode or to : mode. + + +cmd-delete-home (default ), cmd-delete-end (default ) + +Delete everything up to the beginning/end of line. + + +cmd-delete-unix-word (default ) + +Delete the previous unix word. + + +cmd-yank (default ) + +Paste the buffer content containing the last deleted item. + + +cmd-transpose (default ), cmd-transpose-word (default ) + +Transpose the positions of last two characters/words. + + +cmd-word (default ), cmd-word-back (default ) + +Move the cursor by one word in forward/backward direction. + + +cmd-delete-word (default ) + +Delete the next word in forward direction. + + +cmd-delete-word-back (default and ) + +Delete the previous word in backward direction. + + +cmd-capitalize-word (default ), cmd-uppercase-word (default ), cmd-lowercase-word (default ) + +Capitalize/uppercase/lowercase the current word and jump to the next +word. + + + +OPTIONS + + +This section shows information about options to customize the behavior. +Character : is used as the separator for list options []int and +[]string. + + +anchorfind (bool) (default true) + +When this option is enabled, find command starts matching patterns from +the beginning of file names, otherwise, it can match at an arbitrary +position. + + +autoquit (bool) (default false) + +Automatically quit server when there are no clients left connected. + + +borderfmt (string) (default \033[0m) + +Format string of the box drawing characters enabled by the drawbox +option. + + +cleaner (string) (default ``) (not called if empty) + +Set the path of a cleaner file. The file should be executable. This file +is called if previewing is enabled, the previewer is set, and the +previously selected file had its preview cache disabled. The following +arguments are passed to the file, (1) current file name, (2) width, (3) +height, (4) horizontal position, (5) vertical position of preview pane +and (6) next file name to be previewed respectively. Preview cleaning is +disabled when the value of this option is left empty. + + +cursoractivefmt (string) (default \033[7m), cursorparentfmt string (default \033[7m), cursorpreviewfmt string (default \033[4m) + +Format strings for highlighting the cursor. cursoractivefmt applies in +the current directory pane, cursorparentfmt applies in panes that show +parents of the current directory, and cursorpreviewfmt applies in panes +that preview directories. + +The default is to make the active cursor and the parent directory cursor +inverted. The preview cursor is underlined. + +Some other possibilities to consider for the preview or parent cursors: +an empty string for no cursor, \033[7;2m for dimmed inverted text +(visibility varies by terminal), \033[7;90m for inverted text with grey +(aka "brightblack") background. + +If the format string contains the characters %s, it is interpreted as a +format string for fmt.Sprintf. Such a string should end with the +terminal reset sequence. For example, \033[4m%s\033[0m has the same +effect as \033[4m. + + +dircache (bool) (default true) + +Cache directory contents. + + +dircounts (bool) (default false) + +When this option is enabled, directory sizes show the number of items +inside instead of the total size of the directory, which needs to be +calculated for each directory using calcdirsize. This information needs +to be calculated by reading the directory and counting the items inside. +Therefore, this option is disabled by default for performance reasons. +This option only has an effect when info has a size field and the pane +is wide enough to show the information. 999 items are counted per +directory at most, and bigger directories are shown as 999+. + + +dirfirst (bool) (default true) + +Show directories first above regular files. + + +dironly (bool) (default false) + +Show only directories. + + +dirpreviews (bool) (default false) + +If enabled, directories will also be passed to the previewer script. +This allows custom previews for directories. + + +drawbox (bool) (default false) + +Draw boxes around panes with box drawing characters. + + +dupfilefmt (string) (default %f.~%n~) + +Format string of file name when creating duplicate files. With the +default format, copying a file abc.txt to the same directory will result +in a duplicate file called abc.txt.~1~. Special expansions are provided, +%f as the file name, %b for basename (file name without extension), %e +as the extension (including the dot) and %n as the number of duplicates. + + +errorfmt (string) (default \033[7;31;47m) + +Format string of error messages shown in the bottom message line. + +If the format string contains the characters %s, it is interpreted as a +format string for fmt.Sprintf. Such a string should end with the +terminal reset sequence. For example, \033[4m%s\033[0m has the same +effect as \033[4m. + + +filesep (string) (default \n) + +File separator used in environment variables fs and fx. + + +findlen (int) (default 1) + +Number of characters prompted for the find command. When this value is +set to 0, find command prompts until there is only a single match left. + + +globsearch (bool) (default false) + +When this option is enabled, search command patterns are considered as +globs, otherwise they are literals. With globbing, * matches any +sequence, ? matches any character, and [...] or [^...] matches character +sets or ranges. Otherwise, these characters are interpreted as they are. + + +hidden (bool) (default false) + +Show hidden files. On Unix systems, hidden files are determined by the +value of hiddenfiles. On Windows, only files with hidden attributes are +considered hidden files. + + +hiddenfiles ([]string) (default .*) + +List of hidden file glob patterns. Patterns can be given as relative or +absolute paths. Globbing supports the usual special characters, * to +match any sequence, ? to match any character, and [...] or [^...] to +match character sets or ranges. In addition, if a pattern starts with !, +then its matches are excluded from hidden files. To add multiple +patterns, use : as a separator. Example: .*:lost+found:*.bak + + +history (bool) (default true) + +Save command history. + + +icons (bool) (default false) + +Show icons before each item in the list. + + +ifs (string) (default ``) + +Sets IFS variable in shell commands. It works by adding the assignment +to the beginning of the command string as IFS=...; .... The reason is +that IFS variable is not inherited by the shell for security reasons. +This method assumes a POSIX shell syntax and so it can fail for +non-POSIX shells. This option has no effect when the value is left +empty. This option does not have any effect on Windows. + + +ignorecase (bool) (default true) + +Ignore case in sorting and search patterns. + + +ignoredia (bool) (default true) + +Ignore diacritics in sorting and search patterns. + + +incsearch (bool) (default false) + +Jump to the first match after each keystroke during searching. + + +incfilter (bool) (default false) + +Apply filter pattern after each keystroke during filtering. + + +info ([]string) (default ``) + +List of information shown for directory items at the right side of pane. +Currently supported information types are size, time, atime, and ctime. +Information is only shown when the pane width is more than twice the +width of information. + + +infotimefmtnew (string) (default Jan _2 15:04) + +Format string of the file time shown in the info column when it matches +this year. + + +infotimefmtold (string) (default Jan _2 2006) + +Format string of the file time shown in the info column when it doesn't +match this year. + + +mouse (bool) (default false) + +Send mouse events as input. + + +number (bool) (default false) + +Show the position number for directory items at the left side of pane. +When relativenumber option is enabled, only the current line shows the +absolute position and relative positions are shown for the rest. + + +numberfmt (string) (default \033[33m) + +Format string of the position number for each line. + + +period (int) (default 0) + +Set the interval in seconds for periodic checks of directory updates. +This works by periodically calling the load command. 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. Periodic checks are +disabled when the value of this option is set to zero. + + +preserve ([]string) (default mode) + +List of attributes that are preserved when copying files. Currently +supported attributes are mode (i.a. access mode) and timestamps (i.e. +modification time and access time). Note, preserving other attribute +like ownership of change/birth timestamp is desirable, but not portably +supported in Go. + + +preview (bool) (default true) + +Show previews of files and directories at the right most pane. If the +file has more lines than the preview pane, rest of the lines are not +read. Files containing the null character (U+0000) in the read portion +are considered binary files and displayed as binary. + + +previewer (string) (default ``) (not filtered if empty) + +Set the path of a previewer file to filter the content of regular files +for previewing. The file should be executable. The following arguments +are passed to the file, (1) current file name, (2) width, (3) height, +(4) horizontal position, and (5) vertical position of preview pane +respectively. SIGPIPE signal is sent when enough lines are read. If the +previewer returns a non-zero exit code, then the preview cache for the +given file is disabled. This means that if the file is selected in the +future, the previewer is called once again. Preview filtering is +disabled and files are displayed as they are when the value of this +option is left empty. + + +promptfmt (string) (default \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m) + +Format string of the prompt shown in the top line. Special expansions +are provided, %u as the user name, %h as the host name, %w as the +working directory, %d as the working directory with a trailing path +separator, %f as the file name, and %F as the current filter. %S may be +used once and will provide a spacer so that the following parts are +right aligned on the screen. Home folder is shown as ~ in the working +directory expansion. Directory names are automatically shortened to a +single character starting from the left most parent when the prompt does +not fit to the screen. + + +ratios ([]int) (default 1:2:3) + +List of ratios of pane widths. Number of items in the list determines +the number of panes in the ui. When preview option is enabled, the right +most number is used for the width of preview pane. + + +relativenumber (bool) (default false) + +Show the position number relative to the current line. When number is +enabled, current line shows the absolute position, otherwise nothing is +shown. + + +reverse (bool) (default false) + +Reverse the direction of sort. + + +ruler ([]string) (default acc:progress:selection:filter:ind) + +This option is deprecated in favor of using the rulerfmt option (see +below). List of information shown in status line ruler. Currently +supported information types are acc, progress, selection, filter, ind, +df and names starting with lf_. acc shows the pressed keys (e.g. for +bindings with multiple key presses or counts given to bindings). +progress shows the progress of file operations (e.g. copying a large +directory). selection shows the number of files that are selected, or +designated for being cut/copied. filter shows F if a filter is currently +being applied. ind shows the current position of the cursor as well as +the number of files in the current directory. df shows the amount of +free disk space remaining. Names starting with lf_ show the value of +environment variables exported by lf. This is useful for displaying the +current settings (e.g. lf_selmode displays the current setting for the +selmode option). User defined options starting with lf_user_ are also +supported, so it is possible to display information set from external +sources. + + +rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t) + +Format string of the ruler shown in the bottom right corner. Special +expansions are provided, %a as the pressed keys, %p as the progress of +file operations, %m as the number of files to be cut (moved), %c as the +number of files to be copied, %s as the number of selected files, %f as +the filter, %i as the position of the cursor, %t as the number of files +shown in the current directory, %h as the number of files hidden in the +current directory, and %d as the amount of free disk space remaining. +Additional expansions are provided for environment variables exported by +lf, in the form %{lf_} (e.g. %{lf_selmode}). This is useful for +displaying the current settings. Expansions are also provided for user +defined options, in the form %{lf_user_} (e.g. %{lf_user_foo}). +The | character splits the format string into sections. Any section +containing a failed expansion (result is a blank string) is discarded +and not shown. + + +selmode (string) (default all) + +Selection mode for commands. When set to all it will use the selected +files from all directories. When set to dir it will only use the +selected files in the current directory. + + +scrolloff (int) (default 0) + +Minimum number of offset lines shown at all times in the top and the +bottom of the screen when scrolling. The current line is kept in the +middle when this option is set to a large value that is bigger than the +half of number of lines. A smaller offset can be used when the current +file is close to the beginning or end of the list to show the maximum +number of items. + + +shell (string) (default sh for Unix and cmd for Windows) + +Shell executable to use for shell commands. Shell commands are executed +as shell shellopts shellflag command -- arguments. + + +shellflag (string) (default -c for Unix and /c for Windows) + +Command line flag used to pass shell commands. + + +shellopts ([]string) (default ``) + +List of shell options to pass to the shell executable. + + +sixel (bool) (default false) + +Render sixel images in preview. + + +smartcase (bool) (default true) + +Override ignorecase option when the pattern contains an uppercase +character. This option has no effect when ignorecase is disabled. + + +smartdia (bool) (default false) + +Override ignoredia option when the pattern contains a character with +diacritic. This option has no effect when ignoredia is disabled. + + +sortby (string) (default natural) + +Sort type for directories. Currently supported sort types are natural, +name, size, time, ctime, atime, and ext. + + +statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l) + +Format string of the file info shown in the bottom left corner. Special +expansions are provided, %p as the file permissions, %c as the link +count, %u as the user, %g as the group, %s as the file size, %S as the +file size but with a fixed width of four characters (left-padded with +spaces), %t as the last modified time, and %l as the link target. The | +character splits the format string into sections. Any section containing +a failed expansion (result is a blank string) is discarded and not +shown. + + +tabstop (int) (default 8) + +Number of space characters to show for horizontal tabulation (U+0009) +character. + + +tagfmt (string) (default \033[31m) + +Format string of the tags. + +If the format string contains the characters %s, it is interpreted as a +format string for fmt.Sprintf. Such a string should end with the +terminal reset sequence. For example, \033[4m%s\033[0m has the same +effect as \033[4m. + + +tempmarks (string) (default ``) + +Marks to be considered temporary (e.g. abc refers to marks a, b, and c). +These marks are not synced to other clients and they are not saved in +the bookmarks file. Note that the special bookmark ` is always treated +as temporary and it does not need to be specified. + + +timefmt (string) (default Mon Jan _2 15:04:05 2006) + +Format string of the file modification time shown in the bottom line. + + +truncatechar (string) (default ~) + +Truncate character shown at the end when the file name does not fit to +the pane. + + +truncatepct (int) (default 100) + +When a filename is too long to be shown completely, the available space +is partitioned in two pieces. truncatepct defines a fraction (in percent +between 0 and 100) for the size of the first piece, which will show the +beginning of the filename. The second piece will show the end of the +filename and will use the rest of the available space. Both pieces are +separated by the truncation character (truncatechar). A value of 100 +will only show the beginning of the filename, while a value of 0 will +only show the end of the filename, e.g.: + +- set truncatepct 100 -> very-long-filename-tr~ (default) + +- set truncatepct 50 -> very-long-f~-truncated + +- set truncatepct 0 -> ~ng-filename-truncated + + +waitmsg (string) (default Press any key to continue) + +String shown after commands of shell-wait type. + + +wrapscan (bool) (default true) + +Searching can wrap around the file list. + + +wrapscroll (bool) (default false) + +Scrolling can wrap around the file list. + + +user_{option} (string) (default none) + +Any option that is prefixed with user_ is a user defined option and can +be set to any string. Inside a user defined command the value will be +provided in the lf_user_{option} environment variable. These options are +not used by lf and are not persisted. + + + +ENVIRONMENT VARIABLES + + +The following variables are exported for shell commands: These are +referred with a $ prefix on POSIX shells (e.g. $f), between % characters +on Windows cmd (e.g. %f%), and with a $env: prefix on Windows powershell +(e.g. $env:f). + + +f + +Current file selection as a full path. + + +fs + +Selected file(s) separated with the value of filesep option as full +path(s). + + +fx + +Selected file(s) (i.e. fs) if there are any selected files, otherwise +current file selection (i.e. f). + + +id + +Id of the running client. + + +PWD + +Present working directory. + + +OLDPWD + +Initial working directory. + + +LF_LEVEL + +The value of this variable is set to the current nesting level when you +run lf from a shell spawned inside lf. You can add the value of this +variable to your shell prompt to make it clear that your shell runs +inside lf. For example, with POSIX shells, you can use +[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) " in your shell +configuration file (e.g. ~/.bashrc). + + +OPENER + +If this variable is set in the environment, use the same value. +Otherwise, this is set to start in Windows, open in MacOS, xdg-open in +others. + + +EDITOR + +If VISUAL is set in the environment, use its value. Otherwise, use the +value of the environment variable EDITOR. If neither variable is set, +this is set to vi on Unix, notepad in Windows. + + +PAGER + +If this variable is set in the environment, use the same value. +Otherwise, this is set to less on Unix, more in Windows. + + +SHELL + +If this variable is set in the environment, use the same value. +Otherwise, this is set to sh on Unix, cmd in Windows. + + +lf + +Absolute path to the currently running lf binary, if it can be found. +Otherwise, this is set to the string lf. + + +lf_{option} + +Value of the {option}. + + +lf_user_{option} + +Value of the user_{option}. + + +lf_width, lf_height + +Width/Height of the terminal. + + +lf_count + +Value of the count associated with the current command. + + + +SPECIAL COMMANDS + + +This section shows information about special shell commands. + + +open + +This shell command can be defined to override the default open command +when the current file is not a directory. + + +paste + +This shell command can be defined to override the default paste command. + + +rename + +This shell command can be defined to override the default rename +command. + + +delete + +This shell command can be defined to override the default delete +command. + + +pre-cd + +This shell command can be defined to be executed before changing a +directory. + + +on-cd + +This shell command can be defined to be executed after changing a +directory. + + +on-select + +This shell command can be defined to be executed after the selection +changes. + + +on-redraw + +This shell command can be defined to be executed after the screen is +redrawn or if the terminal is resized. + + +on-quit + +This shell command can be defined to be executed before quit. + + + +PREFIXES + + +The following command prefixes are used by lf: + + : read (default) builtin/custom command + $ shell shell command + % shell-pipe shell command running with the ui + ! shell-wait shell command waiting for key press + & shell-async shell command running asynchronously + +The same evaluator is used for the command line and the configuration +file for read and shell commands. The difference is that prefixes are +not necessary in the command line. Instead, different modes are provided +to read corresponding commands. These modes are mapped to the prefix +keys above by default. + + + +SYNTAX + + +Characters from # to newline are comments and ignored: + + # comments start with `#` + +There are five special commands (set, setlocal, map, cmap, and cmd) for +configuration. + +Command set is used to set an option which can be boolean, integer, or +string: + + set hidden # boolean enable + set hidden true # boolean enable + set nohidden # boolean disable + set hidden false # boolean disable + set hidden! # boolean toggle + set scrolloff 10 # integer value + set sortby time # string value w/o quotes + set sortby 'time' # string value with single quotes (whitespaces) + set sortby "time" # string value with double quotes (backslash escapes) + +Command setlocal is used to set a local option for a directory which can +be boolean or string. Currently supported local options are dirfirst, +dironly, hidden, info, reverse, and sortby. Adding a trailing path +separator (i.e. / for Unix and \ for Windows) sets the option for the +given directory along with its subdirectories: + + setlocal /foo/bar hidden # boolean enable + setlocal /foo/bar hidden true # boolean enable + setlocal /foo/bar nohidden # boolean disable + setlocal /foo/bar hidden false # boolean disable + setlocal /foo/bar hidden! # boolean toggle + setlocal /foo/bar sortby time # string value w/o quotes + setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) + setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) + setlocal /foo/bar hidden # for only '/foo/bar' directory + setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') + +Command 'map' is used to bind a key to a command which can be builtin +command, custom command, or shell command: + + map gh cd ~ # builtin command + map D trash # custom command + map i $less $f # shell command + map U !du -csh * # waiting shell command + +Command 'cmap' is used to bind a key on the command line to a command +line command or any other command: + + cmap cmd-escape + cmap set incsearch! + +You can delete an existing binding by leaving the expression empty: + + map gh # deletes 'gh' mapping + cmap # deletes '' mapping + +Command cmd is used to define a custom command: + + cmd usage $du -h -d1 | less + +You can delete an existing command by leaving the expression empty: + + cmd trash # deletes 'trash' command + +If there is no prefix then : is assumed: + + map zt set info time + +An explicit : can be provided to group statements until a newline which +is especially useful for map and cmd commands: + + map st :set sortby time; set info time + +If you need multiline you can wrap statements in {{ and }} after the +proper prefix. + + map st :{{ + set sortby time + set info time + }} + + + +KEY MAPPINGS + + +Regular keys are assigned to a command with the usual syntax: + + map a down + +Keys combined with the shift key simply use the uppercase letter: + + map A down + +Special keys are written in between < and > characters and always use +lowercase letters: + + map down + +Angle brackets can be assigned with their special names: + + map down + map down + +Function keys are prefixed with f character: + + map down + +Keys combined with the control key are prefixed with c character: + + map down + +Keys combined with the alt key are assigned in two different ways +depending on the behavior of your terminal. Older terminals (e.g. xterm) +may set the 8th bit of a character when the alt key is pressed. On these +terminals, you can use the corresponding byte for the mapping: + + map รก down + +Newer terminals (e.g. gnome-terminal) may prefix the key with an escape +key when the alt key is pressed. lf uses the escape delaying mechanism +to recognize alt keys in these terminals (delay is 100ms). On these +terminals, keys combined with the alt key are prefixed with a character: + + map down + +It is possible to combine special keys with modifiers: + + map down + +WARNING: Some key combinations will likely be intercepted by your OS, +window manager, or terminal. Other key combinations cannot be recognized +by lf due to the way terminals work (e.g. Ctrl+h combination sends a +backspace key instead). The easiest way to find out the name of a key +combination and whether it will work on your system is to press the key +while lf is running and read the name from the unknown mapping error. + +Mouse buttons are prefixed with m character: + + map down # primary + map down # secondary + map down # middle + map down + map down + map down + map down + map down + +Mouse wheel events are also prefixed with m character: + + map down + map down + map down + map down + + + +PUSH MAPPINGS + + +The usual way to map a key sequence is to assign it to a named or +unnamed command. While this provides a clean way to remap builtin keys +as well as other commands, it can be limiting at times. For this reason +push command is provided by lf. This command is used to simulate key +pushes given as its arguments. You can map a key to a push command with +an argument to create various keybindings. + +This is mainly useful for two purposes. First, it can be used to map a +command with a command count: + + map push 10j + +Second, it can be used to avoid typing the name when a command takes +arguments: + + map r push :rename + +One thing to be careful is that since push command works with keys +instead of commands it is possible to accidentally create recursive +bindings: + + map j push 2j + +These types of bindings create a deadlock when executed. + + + +SHELL COMMANDS + + +Regular shell commands are the most basic command type that is useful +for many purposes. For example, we can write a shell command to move +selected file(s) to trash. A first attempt to write such a command may +look like this: + + cmd trash ${{ + mkdir -p ~/.trash + if [ -z "$fs" ]; then + mv "$f" ~/.trash + else + IFS="$(printf '\n\t')"; mv $fs ~/.trash + fi + }} + +We check $fs to see if there are any selected files. Otherwise we just +delete the current file. Since this is such a common pattern, a separate +$fx variable is provided. We can use this variable to get rid of the +conditional: + + cmd trash ${{ + mkdir -p ~/.trash + IFS="$(printf '\n\t')"; mv $fx ~/.trash + }} + +The trash directory is checked each time the command is executed. We can +move it outside of the command so it would only run once at startup: + + ${{ mkdir -p ~/.trash }} + + cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} + +Since these are one liners, we can drop {{ and }}: + + $mkdir -p ~/.trash + + cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.trash + +Finally note that we set IFS variable manually in these commands. +Instead we could use the ifs option to set it for all shell commands +(i.e. set ifs "\n"). This can be especially useful for interactive use +(e.g. $rm $f or $rm $fs would simply work). This option is not set by +default as it can behave unexpectedly for new users. However, use of +this option is highly recommended and it is assumed in the rest of the +documentation. + + + +PIPING SHELL COMMANDS + + +Regular shell commands have some limitations in some cases. When an +output or error message is given and the command exits afterwards, the +ui is immediately resumed and there is no way to see the message without +dropping to shell again. Also, even when there is no output or error, +the ui still needs to be paused while the command is running. This can +cause flickering on the screen for short commands and similar +distractions for longer commands. + +Instead of pausing the ui, piping shell commands connects stdin, stdout, +and stderr of the command to the statline in the bottom of the ui. This +can be useful for programs following the Unix philosophy to give no +output in the success case, and brief error messages or prompts in other +cases. + +For example, following rename command prompts for overwrite in the +statline if there is an existing file with the given name: + + cmd rename %mv -i $f $1 + +You can also output error messages in the command and it will show up in +the statline. For example, an alternative rename command may look like +this: + + cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 + +Note that input is line buffered and output and error are byte buffered. + + + +WAITING SHELL COMMANDS + + +Waiting shell commands are similar to regular shell commands except that +they wait for a key press when the command is finished. These can be +useful to see the output of a program before the ui is resumed. Waiting +shell commands are more appropriate than piping shell commands when the +command is verbose and the output is best displayed as multiline. + + + +ASYNCHRONOUS SHELL COMMANDS + + +Asynchronous shell commands are used to start a command in the +background and then resume operation without waiting for the command to +finish. Stdin, stdout, and stderr of the command is neither connected to +the terminal nor to the ui. + + + +REMOTE COMMANDS + + +One of the more advanced features in lf is remote commands. All clients +connect to a server on startup. It is possible to send commands to all +or any of the connected clients over the common server. This is used +internally to notify file selection changes to other clients. + +To use this feature, you need to use a client which supports +communicating with a Unix domain socket. OpenBSD implementation of +netcat (nc) is one such example. You can use it to send a command to the +socket file: + + echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock + +Since such a client may not be available everywhere, lf comes bundled +with a command line flag to be used as such. When using lf, you do not +need to specify the address of the socket file. This is the recommended +way of using remote commands since it is shorter and immune to socket +file address changes: + + lf -remote 'send echo hello world' + +In this command send is used to send the rest of the string as a command +to all connected clients. You can optionally give it an id number to +send a command to a single client: + + lf -remote 'send 1234 echo hello world' + +All clients have a unique id number but you may not be aware of the id +number when you are writing a command. For this purpose, an $id variable +is exported to the environment for shell commands. The value of this +variable is set to the process id of the client. You can use it to send +a remote command from a client to the server which in return sends a +command back to itself. So now you can display a message in the current +client by calling the following in a shell command: + + lf -remote "send $id echo hello world" + +Since lf does not have control flow syntax, remote commands are used for +such needs. For example, you can configure the number of columns in the +ui with respect to the terminal width as follows: + + cmd recol %{{ + if [ $lf_width -le 80 ]; then + lf -remote "send $id set ratios 1:2" + elif [ $lf_width -le 160 ]; then + lf -remote "send $id set ratios 1:2:3" + else + lf -remote "send $id set ratios 1:2:3:5" + fi + }} + +In addition, the query command can be used to obtain information about a +specific lf instance by providing its id: + + lf -remote "query $id maps" + +The following types of information are supported: + + maps list of mappings created by the 'map' command + cmaps list of mappings created by the 'cmap' command + cmds list of commands created by the 'cmd' command + jumps contents of the jump list, showing previously visited locations + history list of previously executed commands on the command line + +This is useful for scripting actions based on the internal state of lf. +For example, to select a previous command using fzf and execute it: + + map ${{ + clear + cmd=$( + lf -remote "query $id history" | + awk -F'\t' 'NR > 1 { print $NF}' | + sort -u | + fzf --reverse --prompt='Execute command: ' + ) + lf -remote "send $id $cmd" + }} + +There is also a quit command to quit the server when there are no +connected clients left, and a quit! command to force quit the server by +closing client connections first: + + lf -remote 'quit' + lf -remote 'quit!' + +Lastly, there is a conn command to connect the server as a client. This +should not be needed for users. + + + +FILE OPERATIONS + + +lf uses its own builtin copy and move operations by default. These are +implemented as asynchronous operations and progress is shown in the +bottom ruler. These commands do not overwrite existing files or +directories with the same name. Instead, a suffix that is compatible +with --backup=numbered option in GNU cp is added to the new files or +directories. Only file modes and (some) timestamps can be preserved (see +preserve option), all other attributes are ignored including ownership, +context, and xattr. Special files such as character and block devices, +named pipes, and sockets are skipped and links are not followed. Moving +is performed using the rename operation of the underlying OS. For +cross-device moving, lf falls back to copying and then deletes the +original files if there are no errors. Operation errors are shown in the +message line as well as the log file and they do not preemptively finish +the corresponding file operation. + +File operations can be performed on the current selected file or +alternatively on multiple files by selecting them first. When you copy a +file, lf doesn't actually copy the file on the disk, but only records +its name to a file. The actual file copying takes place when you paste. +Similarly paste after a cut operation moves the file. + +You can customize copy and move operations by defining a paste command. +This is a special command that is called when it is defined instead of +the builtin implementation. You can use the following example as a +starting point: + + cmd paste %{{ + load=$(cat ~/.local/share/lf/files) + mode=$(echo "$load" | sed -n '1p') + list=$(echo "$load" | sed '1d') + if [ $mode = 'copy' ]; then + cp -R $list . + elif [ $mode = 'move' ]; then + mv $list . + rm ~/.local/share/lf/files + lf -remote 'send clear' + fi + }} + +Some useful things to be considered are to use the backup (--backup) +and/or preserve attributes (-a) options with cp and mv commands if they +support it (i.e. GNU implementation), change the command type to +asynchronous, or use rsync command with progress bar option for copying +and feed the progress to the client periodically with remote echo calls. + +By default, lf does not assign delete command to a key to protect new +users. You can customize file deletion by defining a delete command. You +can also assign a key to this command if you like. An example command to +move selected files to a trash folder and remove files completely after +a prompt are provided in the example configuration file. + + + +SEARCHING FILES + + +There are two mechanisms implemented in lf to search a file in the +current directory. Searching is the traditional method to move the +selection to a file matching a given pattern. Finding is an alternative +way to search for a pattern possibly using fewer keystrokes. + +Searching mechanism is implemented with commands search (default /), +search-back (default ?), search-next (default n), and search-prev +(default N). You can enable globsearch option to match with a glob +pattern. Globbing supports * to match any sequence, ? to match any +character, and [...] or [^...] to match character sets or ranges. You +can enable incsearch option to jump to the current match at each +keystroke while typing. In this mode, you can either use cmd-enter to +accept the search or use cmd-escape to cancel the search. You can also +map some other commands with cmap to accept the search and execute the +command immediately afterwards. For example, you can use the right arrow +key to finish the search and open the selected file with the following +mapping: + + cmap :cmd-enter; open + +Finding mechanism is implemented with commands find (default f), +find-back (default F), find-next (default ;), find-prev (default ,). You +can disable anchorfind option to match a pattern at an arbitrary +position in the filename instead of the beginning. You can set the +number of keys to match using findlen option. If you set this value to +zero, then the the keys are read until there is only a single match. +Default values of these two options are set to jump to the first file +with the given initial. + +Some options effect both searching and finding. You can disable wrapscan +option to prevent searches to wrap around at the end of the file list. +You can disable ignorecase option to match cases in the pattern and the +filename. This option is already automatically overridden if the pattern +contains upper case characters. You can disable smartcase option to +disable this behavior. Two similar options ignoredia and smartdia are +provided to control matching diacritics in latin letters. + + + +OPENING FILES + + +You can define a an open command (default l and ) to configure +file opening. This command is only called when the current file is not a +directory, otherwise the directory is entered instead. You can define it +just as you would define any other command: + + cmd open $vi $fx + +It is possible to use different command types: + + cmd open &xdg-open $f + +You may want to use either file extensions or mime types from file +command: + + cmd open ${{ + case $(file --mime-type -Lb $f) in + text/*) vi $fx;; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; + esac + }} + +You may want to use setsid before your opener command to have persistent +processes that continue to run after lf quits. + +Regular shell commands (i.e. $) drop to terminal which results in a +flicker for commands that finishes immediately (e.g. xdg-open in the +above example). If you want to use asynchronous shell commands (i.e. &) +but also want to use the terminal when necessary (e.g. vi in the above +exxample), you can use a remote command: + + cmd open &{{ + case $(file --mime-type -Lb $f) in + text/*) lf -remote "send $id \$vi \$fx";; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; + esac + }} + +Note, asynchronous shell commands run in their own process group by +default so they do not require the manual use of setsid. + +Following command is provided by default: + + cmd open &$OPENER $f + +You may also use any other existing file openers as you like. Possible +options are libfile-mimeinfo-perl (executable name is mimeopen), rifle +(ranger's default file opener), or mimeo to name a few. + + + +PREVIEWING FILES + + +lf previews files on the preview pane by printing the file until the end +or the preview pane is filled. This output can be enhanced by providing +a custom preview script for filtering. This can be used to highlight +source codes, list contents of archive files or view pdf or image files +to name a few. For coloring lf recognizes ansi escape codes. + +In order 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 file name, (2) width, (3) height, (4) horizontal +position, and (5) vertical position of preview pane respectively. 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 + 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 + + case "$1" in + *.tar*) tar tf "$1";; + *.zip) unzip -l "$1";; + *.rar) unrar l "$1";; + *.7z) 7z l "$1";; + *.pdf) pdftotext "$1" -;; + *) highlight -O ansi "$1";; + esac + +Another important consideration for efficiency is the use of programs +with short startup times for preview. For this reason, highlight is +recommended over pygmentize for syntax highlighting. Besides, it is also +important that the application is processing the file on the fly rather +than first reading it to the memory and then do 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: + + highlight -O ansi "$1" || true + +You may also use an existing preview filter as you like. Your system may +already come with a preview filter named lesspipe. These filters may +have a mechanism to add user customizations as well. See the related +documentations for more information. + + + +CHANGING DIRECTORY + + +lf changes the working directory of the process to the current directory +so that shell commands always work in the displayed directory. After +quitting, it returns to the original directory where it is first +launched like all shell programs. If you want to stay in the current +directory after quitting, you can use one of the example lfcd wrapper +shell scripts provided in the repository at +https://github.com/gokcehan/lf/tree/master/etc + +There is a special command on-cd that runs a shell command when it is +defined and the directory is changed. You can define it just as you +would define any other command: + + cmd on-cd &{{ + bash -c ' + # display git repository status in your prompt + source /usr/share/git/completion/git-prompt.sh + GIT_PS1_SHOWDIRTYSTATE=auto + GIT_PS1_SHOWSTASHSTATE=auto + GIT_PS1_SHOWUNTRACKEDFILES=auto + GIT_PS1_SHOWUPSTREAM=auto + git=$(__git_ps1 " (%s)") + fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f$git\033[0m" + lf -remote "send $id set promptfmt \"$fmt\"" + ' + }} + +If you want to print escape sequences, you may redirect printf output to +/dev/tty. The following xterm specific escape sequence sets the terminal +title to the working directory: + + cmd on-cd &{{ + printf "\033]0; $PWD\007" > /dev/tty + }} + +This command runs whenever you change directory but not on startup. You +can add an extra call to make it run on startup as well: + + cmd on-cd &{{ ... }} + on-cd + +Note that all shell commands are possible but % and & are usually more +appropriate as $ and ! causes flickers and pauses respectively. + +There is also a pre-cd command, that works like on-cd, but is run before +the directory is actually changed. + + + +COLORS + + +lf tries to automatically adapt its colors to the environment. It starts +with a default colorscheme and updates colors using values of existing +environment variables possibly by overwriting its previous values. +Colors are set in the following order: + +1. default +2. LSCOLORS (Mac/BSD ls) +3. LS_COLORS (GNU ls) +4. LF_COLORS (lf specific) +5. colors file (lf specific) + +Please refer to the corresponding man pages for more information about +LSCOLORS and LS_COLORS. LF_COLORS is provided with the same syntax as +LS_COLORS in case you want to configure colors only for lf but not ls. +This can be useful since there are some differences between ls and lf, +though one should expect the same behavior for common cases. Colors file +is provided for easier configuration without environment variables. This +file should consist of whitespace separated pairs with # character to +start comments until the end of line. + +You can configure lf colors in two different ways. First, you can only +configure 8 basic colors used by your terminal and lf should pick up +those colors automatically. Depending on your terminal, you should be +able to select your colors from a 24-bit palette. This is the +recommended approach as colors used by other programs will also match +each other. + +Second, you can set the values of environment variables or colors file +mentioned above for fine grained customization. Note that +LS_COLORS/LF_COLORS are more powerful than LSCOLORS and they can be used +even when GNU programs are not installed on the system. You can combine +this second method with the first method for best results. + +Lastly, you may also want to configure the colors of the prompt line to +match the rest of the colors. Colors of the prompt line can be +configured using the promptfmt option which can include hardcoded colors +as ansi escapes. See the default value of this option to have an idea +about how to color this line. + +It is worth noting that lf uses as many colors advertised by your +terminal's entry in terminfo or infocmp databases on your system. If an +entry is not present, it falls back to an internal database. If your +terminal supports 24-bit colors but either does not have a database +entry or does not advertise all capabilities, you can enable support by +setting the $COLORTERM variable to truecolor or ensuring $TERM is set to +a value that ends with -truecolor. + +Default lf colors are mostly taken from GNU dircolors defaults. These +defaults use 8 basic colors and bold attribute. Default dircolors +entries with background colors are simplified to avoid confusion with +current file selection in lf. Similarly, there are only file type +matchings and extension matchings are left out for simplicity. Default +values are as follows given with their matching order in lf: + + ln 01;36 + or 31;01 + tw 01;34 + ow 01;34 + st 01;34 + di 01;34 + pi 33 + so 01;35 + bd 33;01 + cd 33;01 + su 01;32 + sg 01;32 + ex 01;32 + fi 00 + +Note that lf first tries matching file names and then falls back to file +types. The full order of matchings from most specific to least are as +follows: + +1. Full Path (e.g. ~/.config/lf/lfrc) +2. Dir Name (e.g. .git/) (only matches dirs with a trailing slash at + the end) +3. File Type (e.g. ln) (except fi) +4. File Name (e.g. README*) +5. File Name (e.g. *README) +6. Base Name (e.g. README.*) +7. Extension (e.g. *.txt) +8. Default (i.e. fi) + +For example, given a regular text file /path/to/README.txt, the +following entries are checked in the configuration and the first one to +match is used: + +1. /path/to/README.txt +2. (skipped since the file is not a directory) +3. (skipped since the file is of type fi) +4. README.txt* +5. *README.txt +6. README.* +7. *.txt +8. fi + +Given a regular directory /path/to/example.d, the following entries are +checked in the configuration and the first one to match is used: + +1. /path/to/example.d +2. example.d/ +3. di +4. example.d* +5. *example.d +6. example.* +7. *.d +8. fi + +Note that glob-like patterns do not actually perform glob matching due +to performance reasons. + +For example, you can set a variable as follows: + + export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:" + +Having all entries on a single line can make it hard to read. You may +instead divide it to multiple lines in between double quotes by escaping +newlines with backslashes as follows: + + export LF_COLORS="\ + ~/Documents=01;31:\ + ~/Downloads=01;31:\ + ~/.local/share=01;31:\ + ~/.config/lf/lfrc=31:\ + .git/=01;32:\ + .git*=32:\ + *.gitignore=32:\ + *Makefile=32:\ + README.*=33:\ + *.txt=34:\ + *.md=34:\ + ln=01;36:\ + di=01;34:\ + ex=01;32:\ + " + +Having such a long variable definition in a shell configuration file +might be undesirable. You may instead use the colors file for +configuration. A sample colors file can be found at +https://github.com/gokcehan/lf/blob/master/etc/colors.example You may +also see the wiki page for ansi escape codes +https://en.wikipedia.org/wiki/ANSI_escape_code + + + +ICONS + + +Icons are configured using LF_ICONS environment variable or an icons +file. The variable uses the same syntax as LS_COLORS/LF_COLORS. Instead +of colors, you should put a single characters as values of entries. +Icons file should consist of whitespace separated pairs with # character +to start comments until the end of line. Do not forget to enable icons +option to see the icons. Default values are as follows given with their +matching order in lf: + + ln l + or l + tw t + ow d + st t + di d + pi p + so s + bd b + cd c + su u + sg g + ex x + fi - + +A sample icons file can be found at +https://github.com/gokcehan/lf/blob/master/etc/icons.example diff --git a/docstring.go b/docstring.go deleted file mode 100644 index 9f3e8ef0..00000000 --- a/docstring.go +++ /dev/null @@ -1,1989 +0,0 @@ -// Code generated by gen/docstring.sh DO NOT EDIT. - -package main - -var genDocString = ` -lf is a terminal file manager. - -Source code can be found in the repository at https://github.com/gokcehan/lf - -This documentation can either be read from terminal using 'lf -doc' or -online at https://pkg.go.dev/github.com/gokcehan/lf You can also use 'doc' -command (default '') inside lf to view the documentation in a pager. -A man page with the same content is also available in the repository at -https://github.com/gokcehan/lf/blob/master/lf.1 - -You can run 'lf -help' to see descriptions of command line options. - -# Quick Reference - -The following commands are provided by lf: - - quit (default 'q') - up (default 'k' and '') - half-up (default '') - page-up (default '' and '') - scroll-up (default '') - down (default 'j' and '') - half-down (default '') - page-down (default '' and '') - scroll-down (default '') - updir (default 'h' and '') - open (default 'l' and '') - jump-next (default ']') - jump-prev (default '[') - top (default 'gg' and '') - bottom (default 'G' and '') - high (default 'H') - middle (default 'M') - low (default 'L') - toggle - invert (default 'v') - invert-below - unselect (default 'u') - glob-select - glob-unselect - calcdirsize - clearmaps - copy (default 'y') - cut (default 'd') - paste (default 'p') - clear (default 'c') - sync - draw - redraw (default '') - load - reload (default '') - echo - echomsg - echoerr - cd - select - delete (modal) - rename (modal) (default 'r') - source - push - read (modal) (default ':') - shell (modal) (default '$') - shell-pipe (modal) (default '%') - shell-wait (modal) (default '!') - shell-async (modal) (default '&') - find (modal) (default 'f') - find-back (modal) (default 'F') - find-next (default ';') - find-prev (default ',') - search (modal) (default '/') - search-back (modal) (default '?') - search-next (default 'n') - search-prev (default 'N') - filter (modal) - setfilter - mark-save (modal) (default 'm') - mark-load (modal) (default "'") - mark-remove (modal) (default '"') - tag - tag-toggle (default 't') - -The following command line commands are provided by lf: - - cmd-escape (default '') - cmd-complete (default '') - cmd-menu-complete - cmd-menu-complete-back - cmd-menu-accept - cmd-enter (default '' and '') - cmd-interrupt (default '') - cmd-history-next (default '' and '') - cmd-history-prev (default '' and '') - cmd-left (default '' and '') - cmd-right (default '' and '') - cmd-home (default '' and '') - cmd-end (default '' and '') - cmd-delete (default '' and '') - cmd-delete-back (default '' and '') - cmd-delete-home (default '') - cmd-delete-end (default '') - cmd-delete-unix-word (default '') - cmd-yank (default '') - cmd-transpose (default '') - cmd-transpose-word (default '') - cmd-word (default '') - cmd-word-back (default '') - cmd-delete-word (default '') - cmd-delete-word-back (default '' and '') - cmd-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') - -The following options can be used to customize the behavior of lf: - - anchorfind bool (default true) - autoquit bool (default false) - borderfmt string (default "\033[0m") - cleaner string (default '') - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") - dircache bool (default true) - dircounts bool (default false) - dirfirst bool (default true) - dironly bool (default false) - dirpreviews bool (default false) - drawbox bool (default false) - dupfilefmt string (default '%f.~%n~') - errorfmt string (default "\033[7;31;47m") - filesep string (default "\n") - findlen int (default 1) - globsearch bool (default false) - hidden bool (default false) - hiddenfiles []string (default '.*') - history bool (default true) - icons bool (default false) - ifs string (default '') - ignorecase bool (default true) - ignoredia bool (default true) - incfilter bool (default false) - incsearch bool (default false) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default false) - number bool (default false) - numberfmt string (default "\033[33m") - period int (default 0) - preserve []string (default "mode") - preview bool (default true) - previewer string (default '') - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") - ratios []int (default '1:2:3') - relativenumber bool (default false) - reverse bool (default false) - ruler []string (default 'acc:progress:selection:filter:ind') - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") - scrolloff int (default 0) - selmode string (default 'all') - shell string (default 'sh' for Unix and 'cmd' for Windows) - shellflag string (default '-c' for Unix and '/c' for Windows) - shellopts []string (default '') - sixel bool (default false) - smartcase bool (default true) - smartdia bool (default false) - sortby string (default 'natural') - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") - tabstop int (default 8) - tagfmt string (default "\033[31m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - truncatepct int (default 100) - waitmsg string (default 'Press any key to continue') - wrapscan bool (default true) - wrapscroll bool (default false) - user_{option} string (default none) - -The following environment variables are exported for shell commands: - - f - fs - fx - id - PWD - OLDPWD - LF_LEVEL - OPENER - VISUAL - EDITOR - PAGER - SHELL - lf - lf_{option} - lf_user_{option} - lf_width - lf_height - lf_count - -The following special shell commands are used to customize the behavior of lf -when defined: - - open - paste - rename - delete - pre-cd - on-cd - on-select - on-redraw - on-quit - -The following commands/keybindings are provided by default: - - Unix - cmd open &$OPENER "$f" - map e $$EDITOR "$f" - map i $$PAGER "$f" - map w $$SHELL - cmd doc $$lf -doc | $PAGER - map doc - cmd maps $lf -remote "query $id maps" | $PAGER - cmd cmaps $lf -remote "query $id cmaps" | $PAGER - cmd cmds $lf -remote "query $id cmds" | $PAGER - - Windows - cmd open &%OPENER% %f% - map e $%EDITOR% %f% - map i !%PAGER% %f% - map w $%SHELL% - cmd doc !%lf% -doc | %PAGER% - map doc - cmd maps !%lf% -remote "query %id% maps" | %PAGER% - cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER% - cmd cmds !%lf% -remote "query %id% cmds" | %PAGER% - -The following additional keybindings are provided by default: - - map zh set hidden! - map zr set reverse! - map zn set info - map zs set info size - map zt set info time - map za set info size:time - map sn :set sortby natural; set info - map ss :set sortby size; set info size - map st :set sortby time; set info time - map sa :set sortby atime; set info atime - map sc :set sortby ctime; set info ctime - map se :set sortby ext; set info - map gh cd ~ - map :toggle; down - -If the 'mouse' option is enabled, mouse buttons have the following default -effects: - - Left mouse button - Click on a file or directory to select it. - - Right mouse button - Enter a directory or open a file. Also works on the preview window. - - Scroll wheel - Move up or down. If Ctrl is pressed, scroll up or down. - -# Configuration - -Configuration files should be located at: - - OS system-wide user-specific - Unix /etc/lf/lfrc ~/.config/lf/lfrc - Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Local\lf\lfrc - -Colors file should be located at: - - OS system-wide user-specific - Unix /etc/lf/colors ~/.config/lf/colors - Windows C:\ProgramData\lf\colors C:\Users\\AppData\Local\lf\colors - -Icons file should be located at: - - OS system-wide user-specific - Unix /etc/lf/icons ~/.config/lf/icons - Windows C:\ProgramData\lf\icons C:\Users\\AppData\Local\lf\icons - -Selection file should be located at: - - Unix ~/.local/share/lf/files - Windows C:\Users\\AppData\Local\lf\files - -Marks file should be located at: - - Unix ~/.local/share/lf/marks - Windows C:\Users\\AppData\Local\lf\marks - -Tags file should be located at: - - Unix ~/.local/share/lf/tags - Windows C:\Users\\AppData\Local\lf\tags - -History file should be located at: - - Unix ~/.local/share/lf/history - Windows C:\Users\\AppData\Local\lf\history - -You can configure these locations with the following variables given with their -order of precedences and their default values: - - Unix - $LF_CONFIG_HOME - $XDG_CONFIG_HOME - ~/.config - - $LF_DATA_HOME - $XDG_DATA_HOME - ~/.local/share - - Windows - %ProgramData% - C:\ProgramData - - %LF_CONFIG_HOME% - %LOCALAPPDATA% - C:\Users\\AppData\Local - -A sample configuration file can be found at -https://github.com/gokcehan/lf/blob/master/etc/lfrc.example - -# Commands - -This section shows information about builtin commands. Modal commands do not -take any arguments, but instead change the operation mode to read their input -conveniently, and so they are meant to be assigned to keybindings. - - quit (default 'q') - -Quit lf and return to the shell. - - up (default 'k' and '') - half-up (default '') - page-up (default '' and '') - scroll-up (default '') - down (default 'j' and '') - half-down (default '') - page-down (default '' and '') - scroll-down (default '') - -Move/scroll the current file selection upwards/downwards by one/half a page/full -page. - - updir (default 'h' and '') - -Change the current working directory to the parent directory. - - open (default 'l' and '') - -If the current file is a directory, then change the current directory to it, -otherwise, execute the 'open' command. A default 'open' command is provided -to call the default system opener asynchronously with the current file as the -argument. A custom 'open' command can be defined to override this default. - - jump-next (default ']') - jump-prev (default '[') - -Change the current working directory to the next/previous jumplist item. - - top (default 'gg' and '') - bottom (default 'G' and '') - -Move the current file selection to the top/bottom of the directory. A count can -be specified to move to a specific line, for example use '3G' to move to the -third line. - - high (default 'H') - middle (default 'M') - low (default 'L') - -Move the current file selection to the high/middle/low of the screen. - - toggle - -Toggle the selection of the current file or files given as arguments. - - invert (default 'v') - -Reverse the selection of all files in the current directory (i.e. 'toggle' -all files). Selections in other directories are not effected by this command. -You can define a new command to select all files in the directory by combining -'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this -will also remove selections in other directories. - - invert-below - -Reverse the selection (i.e. 'toggle') of all files at or after the current file -in the current directory. - -To select a contiguous block of files, use this command on the first file you -want to select. Then, move down to the first file you do *not* want to select -(the one after the end of the desired selection) and use this command again. -This achieves an effect similar to the visual mode in vim. - -This command is experimental and may be removed once a better replacement for -the visual mode is implemented in 'lf'. If you'd like to experiment with using -this command, you should bind it to a key (e.g. 'V') for a better experience. - - unselect (default 'u') - -Remove the selection of all files in all directories. - - glob-select - glob-unselect - -Select/unselect files that match the given glob. - - calcdirsize - -Calculate the total size for each of the selected directories. Option 'info' -should include 'size' and option 'dircounts' should be disabled to show this -size. If the total size of a directory is not calculated, it will be shown as -'-'. - - clearmaps - -Remove all keybindings associated with the 'map' command. This command can be -used in the config file to remove the default keybindings. For safety purposes, -':' is left mapped to the 'read' command, and 'cmap' keybindings are retained so -that it is still possible to exit 'lf' using ':quit'. - - copy (default 'y') - -If there are no selections, save the path of the current file to the copy -buffer, otherwise, copy the paths of selected files. - - cut (default 'd') - -If there are no selections, save the path of the current file to the cut buffer, -otherwise, copy the paths of selected files. - - paste (default 'p') - -Copy/Move files in copy/cut buffer to the current working directory. A custom -'paste' command can be defined to override this default. - - clear (default 'c') - -Clear file paths in copy/cut buffer. - - sync - -Synchronize copied/cut files with server. This command is automatically called -when required. - - draw - -Draw the screen. This command is automatically called when required. - - redraw (default '') - -Synchronize the terminal and redraw the screen. - - load - -Load modified files and directories. This command is automatically called when -required. - - reload (default '') - -Flush the cache and reload all files and directories. - - echo - -Print given arguments to the message line at the bottom. - - echomsg - -Print given arguments to the message line at the bottom and also to the log -file. - - echoerr - -Print given arguments to the message line at the bottom as 'errorfmt' and also -to the log file. - - cd - -Change the working directory to the given argument. - - select - -Change the current file selection to the given argument. - - delete (modal) - -Remove the current file or selected file(s). A custom 'delete' command can be -defined to override this default. - - rename (modal) (default 'r') - -Rename the current file using the builtin method. A custom 'rename' command can -be defined to override this default. - - source - -Read the configuration file given in the argument. - - push - -Simulate key pushes given in the argument. - - read (modal) (default ':') - -Read a command to evaluate. - - shell (modal) (default '$') - -Read a shell command to execute. - - shell-pipe (modal) (default '%') - -Read a shell command to execute piping its standard I/O to the bottom statline. - - shell-wait (modal) (default '!') - -Read a shell command to execute and wait for a key press in the end. - - shell-async (modal) (default '&') - -Read a shell command to execute asynchronously without standard I/O. - - find (modal) (default 'f') - find-back (modal) (default 'F') - find-next (default ';') - find-prev (default ',') - -Read key(s) to find the appropriate file name match in the forward/backward -direction and jump to the next/previous match. - - search (default '/') - search-back (default '?') - search-next (default 'n') - search-prev (default 'N') - -Read a pattern to search for a file name match in the forward/backward direction -and jump to the next/previous match. - - filter (modal) - setfilter - -Command 'filter' reads a pattern to filter out and only view files matching -the pattern. Command 'setfilter' does the same but uses an argument to set the -filter immediately. You can supply an argument to 'filter', in order to use that -as the starting prompt. - - mark-save (modal) (default 'm') - -Save the current directory as a bookmark assigned to the given key. - - mark-load (modal) (default "'") - -Change the current directory to the bookmark assigned to the given key. -A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', -or 'select' command. - - mark-remove (modal) (default '"') - -Remove a bookmark assigned to the given key. - - tag - -Tag a file with '*' or a single width character given in the argument. You can -define a new tag clearing command by combining 'tag' with 'tag-toggle' (i.e. -'cmd tag-clear :tag; tag-toggle'). - - tag-toggle (default 't') - -Tag a file with '*' or a single width character given in the argument if the -file is untagged, otherwise remove the tag. - -# Command Line Commands - -The prompt character specifies which of the several command-line modes you are -in. For example, the 'read' command takes you to the ':' mode. - -When the cursor is at the first character in ':' mode, pressing one of the keys -'!', '$', '%', or '&' takes you to the corresponding mode. You can go back with -'cmd-delete-back' ('' by default). - -The command line commands should be mostly compatible with readline keybindings. -A character refers to a unicode code point, a word consists of letters and -digits, and a unix word consists of any non-blank characters. - - cmd-escape (default '') - -Quit command line mode and return to normal mode. - - cmd-complete (default '') - -Autocomplete the current word. - - cmd-menu-complete - cmd-menu-complete-back - -Autocomplete the current word with menu selection. You need to assign -keys to these commands (e.g. 'cmap cmd-menu-complete; cmap -cmd-menu-complete-back'). You can use the assigned keys assigned to display the -menu and then cycle through completion options. - - cmd-menu-accept - -Accept the currently selected match in menu completion and close the menu. - - cmd-enter (default '' and '') - -Execute the current line. - - cmd-interrupt (default '') - -Interrupt the current shell-pipe command and return to the normal mode. - - cmd-history-next (default '' and '') - cmd-history-prev (default '' and '') - -Go to next/previous item in the history. - - cmd-left (default '' and '') - cmd-right (default '' and '') - -Move the cursor to the left/right. - - cmd-home (default '' and '') - cmd-end (default '' and '') - -Move the cursor to the beginning/end of line. - - cmd-delete (default '' and '') - -Delete the next character. - - cmd-delete-back (default '' and '') - -Delete the previous character. When at the beginning of a prompt, returns either -to normal mode or to ':' mode. - - cmd-delete-home (default '') - cmd-delete-end (default '') - -Delete everything up to the beginning/end of line. - - cmd-delete-unix-word (default '') - -Delete the previous unix word. - - cmd-yank (default '') - -Paste the buffer content containing the last deleted item. - - cmd-transpose (default '') - cmd-transpose-word (default '') - -Transpose the positions of last two characters/words. - - cmd-word (default '') - cmd-word-back (default '') - -Move the cursor by one word in forward/backward direction. - - cmd-delete-word (default '') - -Delete the next word in forward direction. - - cmd-delete-word-back (default '' and '') - -Delete the previous word in backward direction. - - cmd-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') - -Capitalize/uppercase/lowercase the current word and jump to the next word. - -# Options - -This section shows information about options to customize the behavior. -Character ':' is used as the separator for list options '[]int' and '[]string'. - - anchorfind bool (default true) - -When this option is enabled, find command starts matching patterns from the -beginning of file names, otherwise, it can match at an arbitrary position. - - autoquit bool (default false) - -Automatically quit server when there are no clients left connected. - - borderfmt string (default "\033[0m") - -Format string of the box drawing characters enabled by the 'drawbox' option. - - cleaner string (default '') (not called if empty) - -Set the path of a cleaner file. The file should be executable. This file is -called if previewing is enabled, the previewer is set, and the previously -selected file had its preview cache disabled. The following arguments are passed -to the file, (1) current file name, (2) width, (3) height, (4) horizontal -position, (5) vertical position of preview pane and (6) next file name to be -previewed respectively. Preview cleaning is disabled when the value of this -option is left empty. - - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") - -Format strings for highlighting the cursor. 'cursoractivefmt' applies in the -current directory pane, 'cursorparentfmt' applies in panes that show parents -of the current directory, and 'cursorpreviewfmt' applies in panes that preview -directories. - -The default is to make the active cursor and the parent directory cursor -inverted. The preview cursor is underlined. - -Some other possibilities to consider for the preview or parent cursors: an empty -string for no cursor, "\033[7;2m" for dimmed inverted text (visibility varies -by terminal), "\033[7;90m" for inverted text with grey (aka "brightblack") -background. - -If the format string contains the characters '%s', it is interpreted as a format -string for 'fmt.Sprintf'. Such a string should end with the terminal reset -sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". - - dircache bool (default true) - -Cache directory contents. - - dircounts bool (default false) - -When this option is enabled, directory sizes show the number of items inside -instead of the total size of the directory, which needs to be calculated for -each directory using 'calcdirsize'. This information needs to be calculated by -reading the directory and counting the items inside. Therefore, this option is -disabled by default for performance reasons. This option only has an effect when -'info' has a 'size' field and the pane is wide enough to show the information. -999 items are counted per directory at most, and bigger directories are shown as -'999+'. - - dirfirst bool (default true) - -Show directories first above regular files. - - dironly bool (default false) - -Show only directories. - - dirpreviews bool (default false) - -If enabled, directories will also be passed to the previewer script. This allows -custom previews for directories. - - drawbox bool (default false) - -Draw boxes around panes with box drawing characters. - - dupfilefmt string (default '%f.~%n~') - -Format string of file name when creating duplicate files. With the default -format, copying a file 'abc.txt' to the same directory will result in a -duplicate file called 'abc.txt.~1~'. Special expansions are provided, '%f' as -the file name, '%b' for basename (file name without extension), '%e' as the -extension (including the dot) and '%n' as the number of duplicates. - - errorfmt string (default "\033[7;31;47m") - -Format string of error messages shown in the bottom message line. - -If the format string contains the characters '%s', it is interpreted as a format -string for 'fmt.Sprintf'. Such a string should end with the terminal reset -sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". - - filesep string (default "\n") - -File separator used in environment variables 'fs' and 'fx'. - - findlen int (default 1) - -Number of characters prompted for the find command. When this value is set to 0, -find command prompts until there is only a single match left. - - globsearch bool (default false) - -When this option is enabled, search command patterns are considered as globs, -otherwise they are literals. With globbing, '*' matches any sequence, '?' -matches any character, and '[...]' or '[^...]' matches character sets or ranges. -Otherwise, these characters are interpreted as they are. - - hidden bool (default false) - -Show hidden files. On Unix systems, hidden files are determined by the value -of 'hiddenfiles'. On Windows, only files with hidden attributes are considered -hidden files. - - hiddenfiles []string (default '.*') - -List of hidden file glob patterns. Patterns can be given as relative or -absolute paths. Globbing supports the usual special characters, '*' to match any -sequence, '?' to match any character, and '[...]' or '[^...]' to match character -sets or ranges. In addition, if a pattern starts with '!', then its matches are -excluded from hidden files. To add multiple patterns, use ':' as a separator. -Example: '.*:lost+found:*.bak' - - history bool (default true) - -Save command history. - - icons bool (default false) - -Show icons before each item in the list. - - ifs string (default '') - -Sets 'IFS' variable in shell commands. It works by adding the assignment to the -beginning of the command string as "IFS='...'; ...". The reason is that 'IFS' -variable is not inherited by the shell for security reasons. This method assumes -a POSIX shell syntax and so it can fail for non-POSIX shells. This option has -no effect when the value is left empty. This option does not have any effect on -Windows. - - ignorecase bool (default true) - -Ignore case in sorting and search patterns. - - ignoredia bool (default true) - -Ignore diacritics in sorting and search patterns. - - incsearch bool (default false) - -Jump to the first match after each keystroke during searching. - - incfilter bool (default false) - -Apply filter pattern after each keystroke during filtering. - - info []string (default '') - -List of information shown for directory items at the right side of pane. -Currently supported information types are 'size', 'time', 'atime', and 'ctime'. -Information is only shown when the pane width is more than twice the width of -information. - - infotimefmtnew string (default 'Jan _2 15:04') - -Format string of the file time shown in the info column when it matches this -year. - - infotimefmtold string (default 'Jan _2 2006') - -Format string of the file time shown in the info column when it doesn't match -this year. - - mouse bool (default false) - -Send mouse events as input. - - number bool (default false) - -Show the position number for directory items at the left side of pane. When -'relativenumber' option is enabled, only the current line shows the absolute -position and relative positions are shown for the rest. - - numberfmt string (default "\033[33m") - -Format string of the position number for each line. - - period int (default 0) - -Set the interval in seconds for periodic checks of directory updates. This works -by periodically calling the 'load' command. 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. Periodic checks are disabled when the value of this option is set to -zero. - - preserve []string (default 'mode') - -List of attributes that are preserved when copying files. Currently supported -attributes are 'mode' (i.a. access mode) and 'timestamps' (i.e. modification -time and access time). Note, preserving other attribute like ownership of -change/birth timestamp is desirable, but not portably supported in Go. - - preview bool (default true) - -Show previews of files and directories at the right most pane. If the file -has more lines than the preview pane, rest of the lines are not read. Files -containing the null character (U+0000) in the read portion are considered binary -files and displayed as 'binary'. - - previewer string (default '') (not filtered if empty) - -Set the path of a previewer file to filter the content of regular files for -previewing. The file should be executable. The following arguments are passed to -the file, (1) current file name, (2) width, (3) height, (4) horizontal position, -and (5) vertical position of preview pane respectively. SIGPIPE signal is sent -when enough lines are read. If the previewer returns a non-zero exit code, -then the preview cache for the given file is disabled. This means that if the -file is selected in the future, the previewer is called once again. Preview -filtering is disabled and files are displayed as they are when the value of this -option is left empty. - - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") - -Format string of the prompt shown in the top line. Special expansions are -provided, '%u' as the user name, '%h' as the host name, '%w' as the working -directory, '%d' as the working directory with a trailing path separator, '%f' as -the file name, and '%F' as the current filter. '%S' may be used once and will -provide a spacer so that the following parts are right aligned on the screen. -Home folder is shown as '~' in the working directory expansion. Directory names -are automatically shortened to a single character starting from the left most -parent when the prompt does not fit to the screen. - - ratios []int (default '1:2:3') - -List of ratios of pane widths. Number of items in the list determines the number -of panes in the ui. When 'preview' option is enabled, the right most number is -used for the width of preview pane. - - relativenumber bool (default false) - -Show the position number relative to the current line. When 'number' is enabled, -current line shows the absolute position, otherwise nothing is shown. - - reverse bool (default false) - -Reverse the direction of sort. - - ruler []string (default 'acc:progress:selection:filter:ind') - -This option is deprecated in favor of using the 'rulerfmt' option (see below). -List of information shown in status line ruler. Currently supported information -types are 'acc', 'progress', 'selection', 'filter', 'ind', 'df' and names -starting with 'lf_'. 'acc' shows the pressed keys (e.g. for bindings with -multiple key presses or counts given to bindings). 'progress' shows the progress -of file operations (e.g. copying a large directory). 'selection' shows the -number of files that are selected, or designated for being cut/copied. 'filter' -shows 'F' if a filter is currently being applied. 'ind' shows the current -position of the cursor as well as the number of files in the current directory. -'df' shows the amount of free disk space remaining. Names starting with 'lf_' -show the value of environment variables exported by lf. This is useful for -displaying the current settings (e.g. 'lf_selmode' displays the current setting -for the 'selmode' option). User defined options starting with 'lf_user_' are -also supported, so it is possible to display information set from external -sources. - - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") - -Format string of the ruler shown in the bottom right corner. Special expansions -are provided, '%a' as the pressed keys, '%p' as the progress of file operations, -'%m' as the number of files to be cut (moved), '%c' as the number of files to -be copied, '%s' as the number of selected files, '%f' as the filter, '%i' as -the position of the cursor, '%t' as the number of files shown in the current -directory, '%h' as the number of files hidden in the current directory, and '%d' -as the amount of free disk space remaining. Additional expansions are provided -for environment variables exported by lf, in the form '%{lf_}' (e.g. -'%{lf_selmode}'). This is useful for displaying the current settings. Expansions -are also provided for user defined options, in the form '%{lf_user_}' -(e.g. '%{lf_user_foo}'). The '|' character splits the format string into -sections. Any section containing a failed expansion (result is a blank string) -is discarded and not shown. - - selmode string (default 'all') - -Selection mode for commands. When set to 'all' it will use the selected files -from all directories. When set to 'dir' it will only use the selected files in -the current directory. - - scrolloff int (default 0) - -Minimum number of offset lines shown at all times in the top and the bottom -of the screen when scrolling. The current line is kept in the middle when this -option is set to a large value that is bigger than the half of number of lines. -A smaller offset can be used when the current file is close to the beginning or -end of the list to show the maximum number of items. - - shell string (default 'sh' for Unix and 'cmd' for Windows) - -Shell executable to use for shell commands. Shell commands are executed as -'shell shellopts shellflag command -- arguments'. - - shellflag string (default '-c' for Unix and '/c' for Windows) - -Command line flag used to pass shell commands. - - shellopts []string (default '') - -List of shell options to pass to the shell executable. - - sixel bool (default false) - -Render sixel images in preview. - - smartcase bool (default true) - -Override 'ignorecase' option when the pattern contains an uppercase character. -This option has no effect when 'ignorecase' is disabled. - - smartdia bool (default false) - -Override 'ignoredia' option when the pattern contains a character with -diacritic. This option has no effect when 'ignoredia' is disabled. - - sortby string (default 'natural') - -Sort type for directories. Currently supported sort types are 'natural', 'name', -'size', 'time', 'ctime', 'atime', and 'ext'. - - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") - -Format string of the file info shown in the bottom left corner. Special -expansions are provided, '%p' as the file permissions, '%c' as the link count, -'%u' as the user, '%g' as the group, '%s' as the file size, '%S' as the file -size but with a fixed width of four characters (left-padded with spaces), '%t' -as the last modified time, and '%l' as the link target. The '|' character splits -the format string into sections. Any section containing a failed expansion -(result is a blank string) is discarded and not shown. - - tabstop int (default 8) - -Number of space characters to show for horizontal tabulation (U+0009) character. - - tagfmt string (default "\033[31m") - -Format string of the tags. - -If the format string contains the characters '%s', it is interpreted as a format -string for 'fmt.Sprintf'. Such a string should end with the terminal reset -sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m". - - tempmarks string (default '') - -Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', -and 'c'). These marks are not synced to other clients and they are not saved -in the bookmarks file. Note that the special bookmark "'" is always treated as -temporary and it does not need to be specified. - - timefmt string (default 'Mon Jan _2 15:04:05 2006') - -Format string of the file modification time shown in the bottom line. - - truncatechar string (default '~') - -Truncate character shown at the end when the file name does not fit to the pane. - - truncatepct int (default 100) - -When a filename is too long to be shown completely, the available space is -partitioned in two pieces. truncatepct defines a fraction (in percent between -0 and 100) for the size of the first piece, which will show the beginning of -the filename. The second piece will show the end of the filename and will use -the rest of the available space. Both pieces are separated by the truncation -character (truncatechar). A value of 100 will only show the beginning of the -filename, while a value of 0 will only show the end of the filename, e.g.: - -- 'set truncatepct 100' -> "very-long-filename-tr~" (default) - -- 'set truncatepct 50' -> "very-long-f~-truncated" - -- 'set truncatepct 0' -> "~ng-filename-truncated" - - waitmsg string (default 'Press any key to continue') - -String shown after commands of shell-wait type. - - wrapscan bool (default true) - -Searching can wrap around the file list. - - wrapscroll bool (default false) - -Scrolling can wrap around the file list. - - user_{option} string (default none) - -Any option that is prefixed with 'user_' is a user defined option and can be set -to any string. Inside a user defined command the value will be provided in the -'lf_user_{option}' environment variable. These options are not used by lf and -are not persisted. - -# Environment Variables - -The following variables are exported for shell commands: These are referred with -a '$' prefix on POSIX shells (e.g. '$f'), between '%' characters on Windows cmd -(e.g. '%f%'), and with a '$env:' prefix on Windows powershell (e.g. '$env:f'). - - f - -Current file selection as a full path. - - fs - -Selected file(s) separated with the value of 'filesep' option as full path(s). - - fx - -Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current -file selection (i.e. 'f'). - - id - -Id of the running client. - - PWD - -Present working directory. - - OLDPWD - -Initial working directory. - - LF_LEVEL - -The value of this variable is set to the current nesting level when you run -lf from a shell spawned inside lf. You can add the value of this variable to -your shell prompt to make it clear that your shell runs inside lf. For example, -with POSIX shells, you can use '[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: -$LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc'). - - OPENER - -If this variable is set in the environment, use the same value. Otherwise, -this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. - - EDITOR - -If VISUAL is set in the environment, use its value. Otherwise, use the value of -the environment variable EDITOR. If neither variable is set, this is set to 'vi' -on Unix, 'notepad' in Windows. - - PAGER - -If this variable is set in the environment, use the same value. Otherwise, -this is set to 'less' on Unix, 'more' in Windows. - - SHELL - -If this variable is set in the environment, use the same value. Otherwise, -this is set to 'sh' on Unix, 'cmd' in Windows. - - lf - -Absolute path to the currently running lf binary, if it can be found. Otherwise, -this is set to the string 'lf'. - - lf_{option} - -Value of the {option}. - - lf_user_{option} - -Value of the user_{option}. - - lf_width - lf_height - -Width/Height of the terminal. - - lf_count - -Value of the count associated with the current command. - -# Special Commands - -This section shows information about special shell commands. - - open - -This shell command can be defined to override the default 'open' command when -the current file is not a directory. - - paste - -This shell command can be defined to override the default 'paste' command. - - rename - -This shell command can be defined to override the default 'rename' command. - - delete - -This shell command can be defined to override the default 'delete' command. - - pre-cd - -This shell command can be defined to be executed before changing a directory. - - on-cd - -This shell command can be defined to be executed after changing a directory. - - on-select - -This shell command can be defined to be executed after the selection changes. - - on-redraw - -This shell command can be defined to be executed after the screen is redrawn or -if the terminal is resized. - - on-quit - -This shell command can be defined to be executed before quit. - -# Prefixes - -The following command prefixes are used by lf: - - : read (default) builtin/custom command - $ shell shell command - % shell-pipe shell command running with the ui - ! shell-wait shell command waiting for key press - & shell-async shell command running asynchronously - -The same evaluator is used for the command line and the configuration file for -read and shell commands. The difference is that prefixes are not necessary in -the command line. Instead, different modes are provided to read corresponding -commands. These modes are mapped to the prefix keys above by default. - -# Syntax - -Characters from '#' to newline are comments and ignored: - - # comments start with '#' - -There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') -for configuration. - -Command 'set' is used to set an option which can be boolean, integer, or string: - - set hidden # boolean enable - set hidden true # boolean enable - set nohidden # boolean disable - set hidden false # boolean disable - set hidden! # boolean toggle - set scrolloff 10 # integer value - set sortby time # string value w/o quotes - set sortby 'time' # string value with single quotes (whitespaces) - set sortby "time" # string value with double quotes (backslash escapes) - -Command 'setlocal' is used to set a local option for a directory which can be -boolean or string. Currently supported local options are 'dirfirst', 'dironly', -'hidden', 'info', 'reverse', and 'sortby'. Adding a trailing path separator -(i.e. '/' for Unix and '\' for Windows) sets the option for the given directory -along with its subdirectories: - - setlocal /foo/bar hidden # boolean enable - setlocal /foo/bar hidden true # boolean enable - setlocal /foo/bar nohidden # boolean disable - setlocal /foo/bar hidden false # boolean disable - setlocal /foo/bar hidden! # boolean toggle - setlocal /foo/bar sortby time # string value w/o quotes - setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) - setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) - setlocal /foo/bar hidden # for only '/foo/bar' directory - setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') - -Command 'map' is used to bind a key to a command which can be builtin command, -custom command, or shell command: - - map gh cd ~ # builtin command - map D trash # custom command - map i $less $f # shell command - map U !du -csh * # waiting shell command - -Command 'cmap' is used to bind a key on the command line to a command line -command or any other command: - - cmap cmd-escape - cmap set incsearch! - -You can delete an existing binding by leaving the expression empty: - - map gh # deletes 'gh' mapping - cmap # deletes '' mapping - -Command 'cmd' is used to define a custom command: - - cmd usage $du -h -d1 | less - -You can delete an existing command by leaving the expression empty: - - cmd trash # deletes 'trash' command - -If there is no prefix then ':' is assumed: - - map zt set info time - -An explicit ':' can be provided to group statements until a newline which is -especially useful for 'map' and 'cmd' commands: - - map st :set sortby time; set info time - -If you need multiline you can wrap statements in '{{' and '}}' after the proper -prefix. - - map st :{{ - set sortby time - set info time - }} - -# Key Mappings - -Regular keys are assigned to a command with the usual syntax: - - map a down - -Keys combined with the shift key simply use the uppercase letter: - - map A down - -Special keys are written in between '<' and '>' characters and always use -lowercase letters: - - map down - -Angle brackets can be assigned with their special names: - - map down - map down - -Function keys are prefixed with 'f' character: - - map down - -Keys combined with the control key are prefixed with 'c' character: - - map down - -Keys combined with the alt key are assigned in two different ways depending on -the behavior of your terminal. Older terminals (e.g. xterm) may set the 8th bit -of a character when the alt key is pressed. On these terminals, you can use the -corresponding byte for the mapping: - - map รก down - -Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when -the alt key is pressed. lf uses the escape delaying mechanism to recognize alt -keys in these terminals (delay is 100ms). On these terminals, keys combined with -the alt key are prefixed with 'a' character: - - map down - -It is possible to combine special keys with modifiers: - - map down - -WARNING: Some key combinations will likely be intercepted by your OS, -window manager, or terminal. Other key combinations cannot be recognized by lf -due to the way terminals work (e.g. 'Ctrl+h' combination sends a backspace key -instead). The easiest way to find out the name of a key combination and whether -it will work on your system is to press the key while lf is running and read the -name from the "unknown mapping" error. - -Mouse buttons are prefixed with 'm' character: - - map down # primary - map down # secondary - map down # middle - map down - map down - map down - map down - map down - -Mouse wheel events are also prefixed with 'm' character: - - map down - map down - map down - map down - -# Push Mappings - -The usual way to map a key sequence is to assign it to a named or unnamed -command. While this provides a clean way to remap builtin keys as well as -other commands, it can be limiting at times. For this reason 'push' command -is provided by lf. This command is used to simulate key pushes given as its -arguments. You can 'map' a key to a 'push' command with an argument to create -various keybindings. - -This is mainly useful for two purposes. First, it can be used to map a command -with a command count: - - map push 10j - -Second, it can be used to avoid typing the name when a command takes arguments: - - map r push :rename - -One thing to be careful is that since 'push' command works with keys instead of -commands it is possible to accidentally create recursive bindings: - - map j push 2j - -These types of bindings create a deadlock when executed. - -# Shell Commands - -Regular shell commands are the most basic command type that is useful for many -purposes. For example, we can write a shell command to move selected file(s) to -trash. A first attempt to write such a command may look like this: - - cmd trash ${{ - mkdir -p ~/.trash - if [ -z "$fs" ]; then - mv "$f" ~/.trash - else - IFS="$(printf '\n\t')"; mv $fs ~/.trash - fi - }} - -We check '$fs' to see if there are any selected files. Otherwise we just delete -the current file. Since this is such a common pattern, a separate '$fx' variable -is provided. We can use this variable to get rid of the conditional: - - cmd trash ${{ - mkdir -p ~/.trash - IFS="$(printf '\n\t')"; mv $fx ~/.trash - }} - -The trash directory is checked each time the command is executed. We can move it -outside of the command so it would only run once at startup: - - ${{ mkdir -p ~/.trash }} - - cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} - -Since these are one liners, we can drop '{{' and '}}': - - $mkdir -p ~/.trash - - cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.trash - -Finally note that we set 'IFS' variable manually in these commands. -Instead we could use the 'ifs' option to set it for all shell commands (i.e. -'set ifs "\n"'). This can be especially useful for interactive use (e.g. -'$rm $f' or '$rm $fs' would simply work). This option is not set by default as -it can behave unexpectedly for new users. However, use of this option is highly -recommended and it is assumed in the rest of the documentation. - -# Piping Shell Commands - -Regular shell commands have some limitations in some cases. When an output or -error message is given and the command exits afterwards, the ui is immediately -resumed and there is no way to see the message without dropping to shell again. -Also, even when there is no output or error, the ui still needs to be paused -while the command is running. This can cause flickering on the screen for short -commands and similar distractions for longer commands. - -Instead of pausing the ui, piping shell commands connects stdin, stdout, -and stderr of the command to the statline in the bottom of the ui. This can -be useful for programs following the Unix philosophy to give no output in the -success case, and brief error messages or prompts in other cases. - -For example, following rename command prompts for overwrite in the statline if -there is an existing file with the given name: - - cmd rename %mv -i $f $1 - -You can also output error messages in the command and it will show up in the -statline. For example, an alternative rename command may look like this: - - cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 - -Note that input is line buffered and output and error are byte buffered. - -# Waiting Shell Commands - -Waiting shell commands are similar to regular shell commands except that they -wait for a key press when the command is finished. These can be useful to see -the output of a program before the ui is resumed. Waiting shell commands are -more appropriate than piping shell commands when the command is verbose and the -output is best displayed as multiline. - -# Asynchronous Shell Commands - -Asynchronous shell commands are used to start a command in the background and -then resume operation without waiting for the command to finish. Stdin, stdout, -and stderr of the command is neither connected to the terminal nor to the ui. - -# Remote Commands - -One of the more advanced features in lf is remote commands. All clients connect -to a server on startup. It is possible to send commands to all or any of the -connected clients over the common server. This is used internally to notify file -selection changes to other clients. - -To use this feature, you need to use a client which supports communicating with -a Unix domain socket. OpenBSD implementation of netcat (nc) is one such example. -You can use it to send a command to the socket file: - - echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock - -Since such a client may not be available everywhere, lf comes bundled with a -command line flag to be used as such. When using lf, you do not need to specify -the address of the socket file. This is the recommended way of using remote -commands since it is shorter and immune to socket file address changes: - - lf -remote 'send echo hello world' - -In this command 'send' is used to send the rest of the string as a command to -all connected clients. You can optionally give it an id number to send a command -to a single client: - - lf -remote 'send 1234 echo hello world' - -All clients have a unique id number but you may not be aware of the id number -when you are writing a command. For this purpose, an '$id' variable is exported -to the environment for shell commands. The value of this variable is set to the -process id of the client. You can use it to send a remote command from a client -to the server which in return sends a command back to itself. So now you can -display a message in the current client by calling the following in a shell -command: - - lf -remote "send $id echo hello world" - -Since lf does not have control flow syntax, remote commands are used for such -needs. For example, you can configure the number of columns in the ui with -respect to the terminal width as follows: - - cmd recol %{{ - if [ $lf_width -le 80 ]; then - lf -remote "send $id set ratios 1:2" - elif [ $lf_width -le 160 ]; then - lf -remote "send $id set ratios 1:2:3" - else - lf -remote "send $id set ratios 1:2:3:5" - fi - }} - -In addition, the 'query' command can be used to obtain information about a -specific lf instance by providing its id: - - lf -remote "query $id maps" - -The following types of information are supported: - - maps list of mappings created by the 'map' command - cmaps list of mappings created by the 'cmap' command - cmds list of commands created by the 'cmd' command - jumps contents of the jump list, showing previously visited locations - history list of previously executed commands on the command line - -This is useful for scripting actions based on the internal state of lf. -For example, to select a previous command using fzf and execute it: - - map ${{ - clear - cmd=$( - lf -remote "query $id history" | - awk -F'\t' 'NR > 1 { print $NF}' | - sort -u | - fzf --reverse --prompt='Execute command: ' - ) - lf -remote "send $id $cmd" - }} - -There is also a 'quit' command to quit the server when there are no connected -clients left, and a 'quit!' command to force quit the server by closing client -connections first: - - lf -remote 'quit' - lf -remote 'quit!' - -Lastly, there is a 'conn' command to connect the server as a client. This should -not be needed for users. - -# File Operations - -lf uses its own builtin copy and move operations by default. These are -implemented as asynchronous operations and progress is shown in the bottom -ruler. These commands do not overwrite existing files or directories with the -same name. Instead, a suffix that is compatible with '--backup=numbered' option -in GNU cp is added to the new files or directories. Only file modes and (some) -timestamps can be preserved (see 'preserve' option), all other attributes are -ignored including ownership, context, and xattr. Special files such as character -and block devices, named pipes, and sockets are skipped and links are not -followed. Moving is performed using the rename operation of the underlying OS. -For cross-device moving, lf falls back to copying and then deletes the original -files if there are no errors. Operation errors are shown in the message line as -well as the log file and they do not preemptively finish the corresponding file -operation. - -File operations can be performed on the current selected file or alternatively -on multiple files by selecting them first. When you 'copy' a file, lf doesn't -actually copy the file on the disk, but only records its name to a file. -The actual file copying takes place when you 'paste'. Similarly 'paste' after a -'cut' operation moves the file. - -You can customize copy and move operations by defining a 'paste' command. This -is a special command that is called when it is defined instead of the builtin -implementation. You can use the following example as a starting point: - - cmd paste %{{ - load=$(cat ~/.local/share/lf/files) - mode=$(echo "$load" | sed -n '1p') - list=$(echo "$load" | sed '1d') - if [ $mode = 'copy' ]; then - cp -R $list . - elif [ $mode = 'move' ]; then - mv $list . - rm ~/.local/share/lf/files - lf -remote 'send clear' - fi - }} - -Some useful things to be considered are to use the backup ('--backup') and/or -preserve attributes ('-a') options with 'cp' and 'mv' commands if they support -it (i.e. GNU implementation), change the command type to asynchronous, or use -'rsync' command with progress bar option for copying and feed the progress to -the client periodically with remote 'echo' calls. - -By default, lf does not assign 'delete' command to a key to protect new users. -You can customize file deletion by defining a 'delete' command. You can also -assign a key to this command if you like. An example command to move selected -files to a trash folder and remove files completely after a prompt are provided -in the example configuration file. - -# Searching Files - -There are two mechanisms implemented in lf to search a file in the current -directory. Searching is the traditional method to move the selection to a file -matching a given pattern. Finding is an alternative way to search for a pattern -possibly using fewer keystrokes. - -Searching mechanism is implemented with commands 'search' (default '/'), -'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' -(default 'N'). You can enable 'globsearch' option to match with a glob pattern. -Globbing supports '*' to match any sequence, '?' to match any character, and -'[...]' or '[^...] to match character sets or ranges. You can enable 'incsearch' -option to jump to the current match at each keystroke while typing. In this -mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' -to cancel the search. You can also map some other commands with 'cmap' to -accept the search and execute the command immediately afterwards. For example, -you can use the right arrow key to finish the search and open the selected file -with the following mapping: - - cmap :cmd-enter; open - -Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' -(default 'F'), 'find-next' (default ';'), 'find-prev' (default ','). You can -disable 'anchorfind' option to match a pattern at an arbitrary position in the -filename instead of the beginning. You can set the number of keys to match using -'findlen' option. If you set this value to zero, then the the keys are read -until there is only a single match. Default values of these two options are set -to jump to the first file with the given initial. - -Some options effect both searching and finding. You can disable 'wrapscan' -option to prevent searches to wrap around at the end of the file list. You can -disable 'ignorecase' option to match cases in the pattern and the filename. -This option is already automatically overridden if the pattern contains upper -case characters. You can disable 'smartcase' option to disable this behavior. -Two similar options 'ignoredia' and 'smartdia' are provided to control matching -diacritics in latin letters. - -# Opening Files - -You can define a an 'open' command (default 'l' and '') to configure file -opening. This command is only called when the current file is not a directory, -otherwise the directory is entered instead. You can define it just as you would -define any other command: - - cmd open $vi $fx - -It is possible to use different command types: - - cmd open &xdg-open $f - -You may want to use either file extensions or mime types from 'file' command: - - cmd open ${{ - case $(file --mime-type -Lb $f) in - text/*) vi $fx;; - *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; - esac - }} - -You may want to use 'setsid' before your opener command to have persistent -processes that continue to run after lf quits. - -Regular shell commands (i.e. '$') drop to terminal which results in a flicker -for commands that finishes immediately (e.g. 'xdg-open' in the above example). -If you want to use asynchronous shell commands (i.e. '&') but also want to use -the terminal when necessary (e.g. 'vi' in the above exxample), you can use a -remote command: - - cmd open &{{ - case $(file --mime-type -Lb $f) in - text/*) lf -remote "send $id \$vi \$fx";; - *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; - esac - }} - -Note, asynchronous shell commands run in their own process group by default so -they do not require the manual use of 'setsid'. - -Following command is provided by default: - - cmd open &$OPENER $f - -You may also use any other existing file openers as you like. Possible options -are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's -default file opener), or 'mimeo' to name a few. - -# Previewing Files - -lf previews files on the preview pane by printing the file until the end or -the preview pane is filled. This output can be enhanced by providing a custom -preview script for filtering. This can be used to highlight source codes, -list contents of archive files or view pdf or image files to name a few. -For coloring lf recognizes ansi escape codes. - -In order 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 file name, (2) width, (3) height, (4) horizontal position, -and (5) vertical position of preview pane respectively. 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 - 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 - - case "$1" in - *.tar*) tar tf "$1";; - *.zip) unzip -l "$1";; - *.rar) unrar l "$1";; - *.7z) 7z l "$1";; - *.pdf) pdftotext "$1" -;; - *) highlight -O ansi "$1";; - esac - -Another important consideration for efficiency is the use of programs with short -startup times for preview. For this reason, 'highlight' is recommended over -'pygmentize' for syntax highlighting. Besides, it is also important that the -application is processing the file on the fly rather than first reading it to -the memory and then do 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: - - highlight -O ansi "$1" || true - -You may also use an existing preview filter as you like. Your system may already -come with a preview filter named 'lesspipe'. These filters may have a mechanism -to add user customizations as well. See the related documentations for more -information. - -# Changing Directory - -lf changes the working directory of the process to the current directory so -that shell commands always work in the displayed directory. After quitting, -it returns to the original directory where it is first launched like all shell -programs. If you want to stay in the current directory after quitting, you can -use one of the example lfcd wrapper shell scripts provided in the repository at -https://github.com/gokcehan/lf/tree/master/etc - -There is a special command 'on-cd' that runs a shell command when it is defined -and the directory is changed. You can define it just as you would define any -other command: - - cmd on-cd &{{ - bash -c ' - # display git repository status in your prompt - source /usr/share/git/completion/git-prompt.sh - GIT_PS1_SHOWDIRTYSTATE=auto - GIT_PS1_SHOWSTASHSTATE=auto - GIT_PS1_SHOWUNTRACKEDFILES=auto - GIT_PS1_SHOWUPSTREAM=auto - git=$(__git_ps1 " (%s)") - fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f$git\033[0m" - lf -remote "send $id set promptfmt \"$fmt\"" - ' - }} - -If you want to print escape sequences, you may redirect 'printf' output to -'/dev/tty'. The following xterm specific escape sequence sets the terminal title -to the working directory: - - cmd on-cd &{{ - printf "\033]0; $PWD\007" > /dev/tty - }} - -This command runs whenever you change directory but not on startup. You can add -an extra call to make it run on startup as well: - - cmd on-cd &{{ ... }} - on-cd - -Note that all shell commands are possible but '%' and '&' are usually more -appropriate as '$' and '!' causes flickers and pauses respectively. - -There is also a 'pre-cd' command, that works like 'on-cd', but is run before the -directory is actually changed. - -# Colors - -lf tries to automatically adapt its colors to the environment. It starts with -a default colorscheme and updates colors using values of existing environment -variables possibly by overwriting its previous values. Colors are set in the -following order: - - 1. default - 2. LSCOLORS (Mac/BSD ls) - 3. LS_COLORS (GNU ls) - 4. LF_COLORS (lf specific) - 5. colors file (lf specific) - -Please refer to the corresponding man pages for more information about -'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as -'LS_COLORS' in case you want to configure colors only for lf but not ls. -This can be useful since there are some differences between ls and lf, though -one should expect the same behavior for common cases. Colors file is provided -for easier configuration without environment variables. This file should consist -of whitespace separated pairs with '#' character to start comments until the end -of line. - -You can configure lf colors in two different ways. First, you can only configure -8 basic colors used by your terminal and lf should pick up those colors -automatically. Depending on your terminal, you should be able to select your -colors from a 24-bit palette. This is the recommended approach as colors used by -other programs will also match each other. - -Second, you can set the values of environment variables or colors file mentioned -above for fine grained customization. Note that 'LS_COLORS/LF_COLORS' are more -powerful than 'LSCOLORS' and they can be used even when GNU programs are not -installed on the system. You can combine this second method with the first -method for best results. - -Lastly, you may also want to configure the colors of the prompt line to match -the rest of the colors. Colors of the prompt line can be configured using the -'promptfmt' option which can include hardcoded colors as ansi escapes. See the -default value of this option to have an idea about how to color this line. - -It is worth noting that lf uses as many colors advertised by your terminal's -entry in terminfo or infocmp databases on your system. If an entry is not -present, it falls back to an internal database. If your terminal supports 24-bit -colors but either does not have a database entry or does not advertise all -capabilities, you can enable support by setting the '$COLORTERM' variable to -'truecolor' or ensuring '$TERM' is set to a value that ends with '-truecolor'. - -Default lf colors are mostly taken from GNU dircolors defaults. These defaults -use 8 basic colors and bold attribute. Default dircolors entries with background -colors are simplified to avoid confusion with current file selection in lf. -Similarly, there are only file type matchings and extension matchings are left -out for simplicity. Default values are as follows given with their matching -order in lf: - - ln 01;36 - or 31;01 - tw 01;34 - ow 01;34 - st 01;34 - di 01;34 - pi 33 - so 01;35 - bd 33;01 - cd 33;01 - su 01;32 - sg 01;32 - ex 01;32 - fi 00 - -Note that lf first tries matching file names and then falls back to file types. -The full order of matchings from most specific to least are as follows: - - 1. Full Path (e.g. '~/.config/lf/lfrc') - 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Type (e.g. 'ln') (except 'fi') - 4. File Name (e.g. 'README*') - 5. File Name (e.g. '*README') - 6. Base Name (e.g. 'README.*') - 7. Extension (e.g. '*.txt') - 8. Default (i.e. 'fi') - -For example, given a regular text file '/path/to/README.txt', the following -entries are checked in the configuration and the first one to match is used: - - 1. '/path/to/README.txt' - 2. (skipped since the file is not a directory) - 3. (skipped since the file is of type 'fi') - 4. 'README.txt*' - 5. '*README.txt' - 6. 'README.*' - 7. '*.txt' - 8. 'fi' - -Given a regular directory '/path/to/example.d', the following entries are -checked in the configuration and the first one to match is used: - - 1. '/path/to/example.d' - 2. 'example.d/' - 3. 'di' - 4. 'example.d*' - 5. '*example.d' - 6. 'example.*' - 7. '*.d' - 8. 'fi' - -Note that glob-like patterns do not actually perform glob matching due to -performance reasons. - -For example, you can set a variable as follows: - - export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:" - -Having all entries on a single line can make it hard to read. You may instead -divide it to multiple lines in between double quotes by escaping newlines with -backslashes as follows: - - export LF_COLORS="\ - ~/Documents=01;31:\ - ~/Downloads=01;31:\ - ~/.local/share=01;31:\ - ~/.config/lf/lfrc=31:\ - .git/=01;32:\ - .git*=32:\ - *.gitignore=32:\ - *Makefile=32:\ - README.*=33:\ - *.txt=34:\ - *.md=34:\ - ln=01;36:\ - di=01;34:\ - ex=01;32:\ - " - -Having such a long variable definition in a shell configuration -file might be undesirable. You may instead use the colors -file for configuration. A sample colors file can be found at -https://github.com/gokcehan/lf/blob/master/etc/colors.example -You may also see the wiki page for ansi escape codes -https://en.wikipedia.org/wiki/ANSI_escape_code - -# Icons - -Icons are configured using 'LF_ICONS' environment variable or an icons file. -The variable uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of colors, -you should put a single characters as values of entries. Icons file should -consist of whitespace separated pairs with '#' character to start comments -until the end of line. Do not forget to enable 'icons' option to see the icons. -Default values are as follows given with their matching order in lf: - - ln l - or l - tw t - ow d - st t - di d - pi p - so s - bd b - cd c - su u - sg g - ex x - fi - - -A sample icons file can be found at -https://github.com/gokcehan/lf/blob/master/etc/icons.example -` diff --git a/gen/doc.sh b/gen/doc.sh new file mode 100755 index 00000000..7f2df743 --- /dev/null +++ b/gen/doc.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Generates `lf.1` and `doc.txt` from the `doc.md` file. +# +# This script is used to generate a man page and a plain text conversion of the +# markdown documentation using pandoc (https://pandoc.org/). GitHub Flavored +# Markdown (GFM) (https://github.github.com/gfm/) is used for the markdown +# input format. The markdown file is automatically rendered in the GitHub +# repository (https://github.com/gokcehan/lf/blob/master/doc.md). The man page +# file `lf.1` is meant to be used for installations on Unix systems. The plain +# text file `doc.txt` is embedded in the binary to be displayed on request with +# the `-doc` command line flag. Thus the same documentation is used for online +# and terminal display. + +[ -z $version ] && version=$(git describe --tags) +[ -z $date ] && date=$(date +%F) + +pandoc \ + --standalone \ + --from gfm --to man \ + --metadata=title:"LF" \ + --metadata=section:"1" \ + --metadata=date:"$date" \ + --metadata=footer:"$version" \ + --metadata=header:"DOCUMENTATION" \ + doc.md -o lf.1 + +pandoc \ + --standalone \ + --from gfm --to plain \ + doc.md -o doc.txt diff --git a/gen/docstring.sh b/gen/docstring.sh deleted file mode 100755 index def15aa9..00000000 --- a/gen/docstring.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Generates `docstring.go` having `genDocString` variable with `go doc` output. -# -# This script is called in `doc.go` using `go generate` to embed the -# documentation inside the binary in order to show it on request with `-doc` -# command line flag. Thus the same documentation is used for online and -# terminal display. - -tmp=gen/docstring.go - -echo "// Code generated by gen/docstring.sh DO NOT EDIT." >> $tmp -echo >> $tmp -echo "package main" >> $tmp -echo >> $tmp -echo "var genDocString = \`" >> $tmp -go doc | tr "\`" "'" >> $tmp -echo "\`" >> $tmp - -mv $tmp docstring.go diff --git a/gen/man.sh b/gen/man.sh deleted file mode 100755 index 2af92873..00000000 --- a/gen/man.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# Generates `lf.1` man page using man macros with `go doc` output. -# -# This script is called in `doc.go` using `go generate` to generate a man page -# formatted with man macros from the documentation. A few additional sections -# such as `NAME` and `SYNOPSIS` are added to comply with man page conventions. -# -# Conversion logic implemented here from godoc output to man macros should not -# be considered compliant, as such it has inexact assumptions such as the use -# of spaces over tabs along with various corner cases that are not handled -# properly like character escaping. The intention here is to come up with -# something that can convert the current content in the documentation. For this -# reason, it is recommended to check the output after generation especially -# when the documentation is changed in a significant way. - -out=lf.1 - -echo '.\" Code generated by gen/man.sh DO NOT EDIT.' > $out - -cat << END >> $out -.TH LF 1 -.SH NAME -lf \- terminal file manager -.SH SYNOPSIS -.SY lf -.OP \-command command -.OP \-config path -.OP \-cpuprofile path -.OP \-doc -.OP \-last-dir-path path -.OP \-log path -.OP \-memprofile path -.OP \-remote command -.OP \-selection-path path -.OP \-server -.OP \-single -.OP \-version -.OP \-help -.RI [ cd-or-select-path ] -.YS -.SH DESCRIPTION -END - -go doc | awk ' -BEGIN { - RS = "" - start = 1 -} - -# preformatted -/^ / { - gsub("\\\\", "\\e", $0) - print ".PP" - print ".EX" - print $0 - print ".EE" - next -} - -# heading -/^# *[^[:punct:]]*$/ { - gsub(/# */, "", $0) - print ".SH", toupper($0) - start = 1 - next -} - -# paragraph -{ - gsub("\n", " ", $0) - gsub("\\\\", "\\e", $0) - if (start) { start = 0 } else { print ".PP" } - print $0 -} -' >> $out diff --git a/lf.1 b/lf.1 index e9f98903..826d604a 100644 --- a/lf.1 +++ b/lf.1 @@ -1,1991 +1,2378 @@ -.\" Code generated by gen/man.sh DO NOT EDIT. -.TH LF 1 +.\" Automatically generated by Pandoc 2.5 +.\" +.TH "LF" "1" "2023\-11\-06" "r31\-17\-g31402e6" "DOCUMENTATION" +.hy .SH NAME +.PP lf \- terminal file manager .SH SYNOPSIS -.SY lf -.OP \-command command -.OP \-config path -.OP \-cpuprofile path -.OP \-doc -.OP \-last-dir-path path -.OP \-log path -.OP \-memprofile path -.OP \-remote command -.OP \-selection-path path -.OP \-server -.OP \-single -.OP \-version -.OP \-help -.RI [ cd-or-select-path ] -.YS +.PP +\f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R] +\f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]] +[\f[B]\-doc\f[R]] [\f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]] +[\f[B]\-log path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]] +[\f[B]\-print\-last\-dir\f[R]] [\f[B]\-print\-selection\f[R]] +[\f[B]\-remote\f[R] \f[I]command\f[R]] [\f[B]\-selection\-path\f[R] +\f[I]path\f[R]] [\f[B]\-server\f[R]] [\f[B]\-single\f[R]] +[\f[B]\-version\f[R]] [\f[B]\-help\f[R]] +[\f[I]cd\-or\-select\-path\f[R]] .SH DESCRIPTION +.PP lf is a terminal file manager. .PP -Source code can be found in the repository at https://github.com/gokcehan/lf +Source code can be found in the repository at +https://github.com/gokcehan/lf (https://github.com/gokcehan/lf) .PP -This documentation can either be read from terminal using 'lf -doc' or online at https://pkg.go.dev/github.com/gokcehan/lf You can also use 'doc' command (default '') inside lf to view the documentation in a pager. A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1 +This documentation can either be read from terminal using +\f[C]lf \-doc\f[R] or online at +https://github.com/gokcehan/lf/blob/master/doc.md (https://github.com/gokcehan/lf/blob/master/doc.md) +You can also use \f[C]doc\f[R] command (default \f[C]\f[R]) inside +lf to view the documentation in a pager. +A man page with the same content is also available in the repository at +https://github.com/gokcehan/lf/blob/master/lf.1 (https://github.com/gokcehan/lf/blob/master/lf.1) .PP -You can run 'lf -help' to see descriptions of command line options. +You can run \f[C]lf \-help\f[R] to see descriptions of command line +options. .SH QUICK REFERENCE -The following commands are provided by lf: .PP -.EX - quit (default 'q') - up (default 'k' and '') - half-up (default '') - page-up (default '' and '') - scroll-up (default '') - down (default 'j' and '') - half-down (default '') - page-down (default '' and '') - scroll-down (default '') - updir (default 'h' and '') - open (default 'l' and '') - jump-next (default ']') - jump-prev (default '[') - top (default 'gg' and '') - bottom (default 'G' and '') - high (default 'H') - middle (default 'M') - low (default 'L') - toggle - invert (default 'v') - invert-below - unselect (default 'u') - glob-select - glob-unselect - calcdirsize - clearmaps - copy (default 'y') - cut (default 'd') - paste (default 'p') - clear (default 'c') - sync - draw - redraw (default '') - load - reload (default '') - echo - echomsg - echoerr - cd - select - delete (modal) - rename (modal) (default 'r') - source - push - read (modal) (default ':') - shell (modal) (default '$') - shell-pipe (modal) (default '%') - shell-wait (modal) (default '!') - shell-async (modal) (default '&') - find (modal) (default 'f') - find-back (modal) (default 'F') - find-next (default ';') - find-prev (default ',') - search (modal) (default '/') - search-back (modal) (default '?') - search-next (default 'n') - search-prev (default 'N') - filter (modal) - setfilter - mark-save (modal) (default 'm') - mark-load (modal) (default "'") - mark-remove (modal) (default '"') - tag - tag-toggle (default 't') -.EE +The following commands are provided by lf: +.IP +.nf +\f[C] +quit (default \[aq]q\[aq]) +up (default \[aq]k\[aq] and \[aq]\[aq]) +half\-up (default \[aq]\[aq]) +page\-up (default \[aq]\[aq] and \[aq]\[aq]) +scroll\-up (default \[aq]\[aq]) +down (default \[aq]j\[aq] and \[aq]\[aq]) +half\-down (default \[aq]\[aq]) +page\-down (default \[aq]\[aq] and \[aq]\[aq]) +scroll\-down (default \[aq]\[aq]) +updir (default \[aq]h\[aq] and \[aq]\[aq]) +open (default \[aq]l\[aq] and \[aq]\[aq]) +jump\-next (default \[aq]]\[aq]) +jump\-prev (default \[aq][\[aq]) +top (default \[aq]gg\[aq] and \[aq]\[aq]) +bottom (default \[aq]G\[aq] and \[aq]\[aq]) +high (default \[aq]H\[aq]) +middle (default \[aq]M\[aq]) +low (default \[aq]L\[aq]) +toggle +invert (default \[aq]v\[aq]) +invert\-below +unselect (default \[aq]u\[aq]) +glob\-select +glob\-unselect +calcdirsize +clearmaps +copy (default \[aq]y\[aq]) +cut (default \[aq]d\[aq]) +paste (default \[aq]p\[aq]) +clear (default \[aq]c\[aq]) +sync +draw +redraw (default \[aq]\[aq]) +load +reload (default \[aq]\[aq]) +echo +echomsg +echoerr +cd +select +delete (modal) +rename (modal) (default \[aq]r\[aq]) +source +push +read (modal) (default \[aq]:\[aq]) +shell (modal) (default \[aq]$\[aq]) +shell\-pipe (modal) (default \[aq]%\[aq]) +shell\-wait (modal) (default \[aq]!\[aq]) +shell\-async (modal) (default \[aq]&\[aq]) +find (modal) (default \[aq]f\[aq]) +find\-back (modal) (default \[aq]F\[aq]) +find\-next (default \[aq];\[aq]) +find\-prev (default \[aq],\[aq]) +search (modal) (default \[aq]/\[aq]) +search\-back (modal) (default \[aq]?\[aq]) +search\-next (default \[aq]n\[aq]) +search\-prev (default \[aq]N\[aq]) +filter (modal) +setfilter +mark\-save (modal) (default \[aq]m\[aq]) +mark\-load (modal) (default \[dq]\[aq]\[dq]) +mark\-remove (modal) (default \[aq]\[dq]\[aq]) +tag +tag\-toggle (default \[aq]t\[aq]) +\f[R] +.fi .PP The following command line commands are provided by lf: -.PP -.EX - cmd-escape (default '') - cmd-complete (default '') - cmd-menu-complete - cmd-menu-complete-back - cmd-menu-accept - cmd-enter (default '' and '') - cmd-interrupt (default '') - cmd-history-next (default '' and '') - cmd-history-prev (default '' and '') - cmd-left (default '' and '') - cmd-right (default '' and '') - cmd-home (default '' and '') - cmd-end (default '' and '') - cmd-delete (default '' and '') - cmd-delete-back (default '' and '') - cmd-delete-home (default '') - cmd-delete-end (default '') - cmd-delete-unix-word (default '') - cmd-yank (default '') - cmd-transpose (default '') - cmd-transpose-word (default '') - cmd-word (default '') - cmd-word-back (default '') - cmd-delete-word (default '') - cmd-delete-word-back (default '' and '') - cmd-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') -.EE +.IP +.nf +\f[C] +cmd\-escape (default \[aq]\[aq]) +cmd\-complete (default \[aq]\[aq]) +cmd\-menu\-complete +cmd\-menu\-complete\-back +cmd\-menu\-accept +cmd\-enter (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-interrupt (default \[aq]\[aq]) +cmd\-history\-next (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-history\-prev (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-left (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-right (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-home (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-end (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-delete (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-delete\-back (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-delete\-home (default \[aq]\[aq]) +cmd\-delete\-end (default \[aq]\[aq]) +cmd\-delete\-unix\-word (default \[aq]\[aq]) +cmd\-yank (default \[aq]\[aq]) +cmd\-transpose (default \[aq]\[aq]) +cmd\-transpose\-word (default \[aq]\[aq]) +cmd\-word (default \[aq]\[aq]) +cmd\-word\-back (default \[aq]\[aq]) +cmd\-delete\-word (default \[aq]\[aq]) +cmd\-delete\-word\-back (default \[aq]\[aq] and \[aq]\[aq]) +cmd\-capitalize\-word (default \[aq]\[aq]) +cmd\-uppercase\-word (default \[aq]\[aq]) +cmd\-lowercase\-word (default \[aq]\[aq]) +\f[R] +.fi .PP The following options can be used to customize the behavior of lf: -.PP -.EX - anchorfind bool (default true) - autoquit bool (default false) - borderfmt string (default "\e033[0m") - cleaner string (default '') - cursoractivefmt string (default "\e033[7m") - cursorparentfmt string (default "\e033[7m") - cursorpreviewfmt string (default "\e033[4m") - dircache bool (default true) - dircounts bool (default false) - dirfirst bool (default true) - dironly bool (default false) - dirpreviews bool (default false) - drawbox bool (default false) - dupfilefmt string (default '%f.~%n~') - errorfmt string (default "\e033[7;31;47m") - filesep string (default "\en") - findlen int (default 1) - globsearch bool (default false) - hidden bool (default false) - hiddenfiles []string (default '.*') - history bool (default true) - icons bool (default false) - ifs string (default '') - ignorecase bool (default true) - ignoredia bool (default true) - incfilter bool (default false) - incsearch bool (default false) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default false) - number bool (default false) - numberfmt string (default "\e033[33m") - period int (default 0) - preserve []string (default "mode") - preview bool (default true) - previewer string (default '') - promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m") - ratios []int (default '1:2:3') - relativenumber bool (default false) - reverse bool (default false) - ruler []string (default 'acc:progress:selection:filter:ind') - rulerfmt string (default " %a| %p| \e033[7;31m %m \e033[0m| \e033[7;33m %c \e033[0m| \e033[7;35m %s \e033[0m| \e033[7;34m %f \e033[0m| %i/%t") - scrolloff int (default 0) - selmode string (default 'all') - shell string (default 'sh' for Unix and 'cmd' for Windows) - shellflag string (default '-c' for Unix and '/c' for Windows) - shellopts []string (default '') - sixel bool (default false) - smartcase bool (default true) - smartdia bool (default false) - sortby string (default 'natural') - statfmt string (default "\e033[36m%p\e033[0m| %c| %u| %g| %S| %t| -> %l") - tabstop int (default 8) - tagfmt string (default "\e033[31m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - truncatepct int (default 100) - waitmsg string (default 'Press any key to continue') - wrapscan bool (default true) - wrapscroll bool (default false) - user_{option} string (default none) -.EE +.IP +.nf +\f[C] +anchorfind bool (default true) +autoquit bool (default false) +borderfmt string (default \[dq]\[rs]033[0m\[dq]) +cleaner string (default \[aq]\[aq]) +cursoractivefmt string (default \[dq]\[rs]033[7m\[dq]) +cursorparentfmt string (default \[dq]\[rs]033[7m\[dq]) +cursorpreviewfmt string (default \[dq]\[rs]033[4m\[dq]) +dircache bool (default true) +dircounts bool (default false) +dirfirst bool (default true) +dironly bool (default false) +dirpreviews bool (default false) +drawbox bool (default false) +dupfilefmt string (default \[aq]%f.\[ti]%n\[ti]\[aq]) +errorfmt string (default \[dq]\[rs]033[7;31;47m\[dq]) +filesep string (default \[dq]\[rs]n\[dq]) +findlen int (default 1) +globsearch bool (default false) +hidden bool (default false) +hiddenfiles []string (default \[aq].*\[aq]) +history bool (default true) +icons bool (default false) +ifs string (default \[aq]\[aq]) +ignorecase bool (default true) +ignoredia bool (default true) +incfilter bool (default false) +incsearch bool (default false) +info []string (default \[aq]\[aq]) +infotimefmtnew string (default \[aq]Jan _2 15:04\[aq]) +infotimefmtold string (default \[aq]Jan _2 2006\[aq]) +mouse bool (default false) +number bool (default false) +numberfmt string (default \[dq]\[rs]033[33m\[dq]) +period int (default 0) +preserve []string (default \[dq]mode\[dq]) +preview bool (default true) +previewer string (default \[aq]\[aq]) +promptfmt string (default \[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f\[rs]033[0m\[dq]) +ratios []int (default \[aq]1:2:3\[aq]) +relativenumber bool (default false) +reverse bool (default false) +ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq]) +rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq]) +scrolloff int (default 0) +selmode string (default \[aq]all\[aq]) +shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows) +shellflag string (default \[aq]\-c\[aq] for Unix and \[aq]/c\[aq] for Windows) +shellopts []string (default \[aq]\[aq]) +sixel bool (default false) +smartcase bool (default true) +smartdia bool (default false) +sortby string (default \[aq]natural\[aq]) +statfmt string (default \[dq]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| \-> %l\[dq]) +tabstop int (default 8) +tagfmt string (default \[dq]\[rs]033[31m\[dq]) +tempmarks string (default \[aq]\[aq]) +timefmt string (default \[aq]Mon Jan _2 15:04:05 2006\[aq]) +truncatechar string (default \[aq]\[ti]\[aq]) +truncatepct int (default 100) +waitmsg string (default \[aq]Press any key to continue\[aq]) +wrapscan bool (default true) +wrapscroll bool (default false) +user_{option} string (default none) +\f[R] +.fi .PP The following environment variables are exported for shell commands: +.IP +.nf +\f[C] +f +fs +fx +id +PWD +OLDPWD +LF_LEVEL +OPENER +VISUAL +EDITOR +PAGER +SHELL +lf +lf_{option} +lf_user_{option} +lf_width +lf_height +lf_count +\f[R] +.fi .PP -.EX - f - fs - fx - id - PWD - OLDPWD - LF_LEVEL - OPENER - VISUAL - EDITOR - PAGER - SHELL - lf - lf_{option} - lf_user_{option} - lf_width - lf_height - lf_count -.EE -.PP -The following special shell commands are used to customize the behavior of lf when defined: -.PP -.EX - open - paste - rename - delete - pre-cd - on-cd - on-select - on-redraw - on-quit -.EE +The following special shell commands are used to customize the behavior +of lf when defined: +.IP +.nf +\f[C] +open +paste +rename +delete +pre\-cd +on\-cd +on\-select +on\-redraw +on\-quit +\f[R] +.fi .PP The following commands/keybindings are provided by default: -.PP -.EX - Unix - cmd open &$OPENER "$f" - map e $$EDITOR "$f" - map i $$PAGER "$f" - map w $$SHELL - cmd doc $$lf -doc | $PAGER - map doc - cmd maps $lf -remote "query $id maps" | $PAGER - cmd cmaps $lf -remote "query $id cmaps" | $PAGER - cmd cmds $lf -remote "query $id cmds" | $PAGER -.EE -.PP -.EX - Windows - cmd open &%OPENER% %f% - map e $%EDITOR% %f% - map i !%PAGER% %f% - map w $%SHELL% - cmd doc !%lf% -doc | %PAGER% - map doc - cmd maps !%lf% -remote "query %id% maps" | %PAGER% - cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER% - cmd cmds !%lf% -remote "query %id% cmds" | %PAGER% -.EE +.IP +.nf +\f[C] +Unix +cmd open &$OPENER \[dq]$f\[dq] +map e $$EDITOR \[dq]$f\[dq] +map i $$PAGER \[dq]$f\[dq] +map w $$SHELL +cmd doc $$lf \-doc | $PAGER +map doc +cmd maps $lf \-remote \[dq]query $id maps\[dq] | $PAGER +cmd cmaps $lf \-remote \[dq]query $id cmaps\[dq] | $PAGER +cmd cmds $lf \-remote \[dq]query $id cmds\[dq] | $PAGER + +Windows +cmd open &%OPENER% %f% +map e $%EDITOR% %f% +map i !%PAGER% %f% +map w $%SHELL% +cmd doc !%lf% \-doc | %PAGER% +map doc +cmd maps !%lf% \-remote \[dq]query %id% maps\[dq] | %PAGER% +cmd cmaps !%lf% \-remote \[dq]query %id% cmaps\[dq] | %PAGER% +cmd cmds !%lf% \-remote \[dq]query %id% cmds\[dq] | %PAGER% +\f[R] +.fi .PP The following additional keybindings are provided by default: +.IP +.nf +\f[C] +map zh set hidden! +map zr set reverse! +map zn set info +map zs set info size +map zt set info time +map za set info size:time +map sn :set sortby natural; set info +map ss :set sortby size; set info size +map st :set sortby time; set info time +map sa :set sortby atime; set info atime +map sc :set sortby ctime; set info ctime +map se :set sortby ext; set info +map gh cd \[ti] +map :toggle; down +\f[R] +.fi .PP -.EX - map zh set hidden! - map zr set reverse! - map zn set info - map zs set info size - map zt set info time - map za set info size:time - map sn :set sortby natural; set info - map ss :set sortby size; set info size - map st :set sortby time; set info time - map sa :set sortby atime; set info atime - map sc :set sortby ctime; set info ctime - map se :set sortby ext; set info - map gh cd ~ - map :toggle; down -.EE -.PP -If the 'mouse' option is enabled, mouse buttons have the following default effects: -.PP -.EX - Left mouse button - Click on a file or directory to select it. -.EE -.PP -.EX - Right mouse button - Enter a directory or open a file. Also works on the preview window. -.EE -.PP -.EX - Scroll wheel - Move up or down. If Ctrl is pressed, scroll up or down. -.EE +If the \f[C]mouse\f[R] option is enabled, mouse buttons have the +following default effects: +.IP +.nf +\f[C] +Left mouse button + Click on a file or directory to select it. + +Right mouse button + Enter a directory or open a file. Also works on the preview window. + +Scroll wheel + Move up or down. If Ctrl is pressed, scroll up or down. +\f[R] +.fi .SH CONFIGURATION -Configuration files should be located at: .PP -.EX - OS system-wide user-specific - Unix /etc/lf/lfrc ~/.config/lf/lfrc - Windows C:\eProgramData\elf\elfrc C:\eUsers\e\eAppData\eLocal\elf\elfrc -.EE +Configuration files should be located at: +.IP +.nf +\f[C] +OS system\-wide user\-specific +Unix /etc/lf/lfrc \[ti]/.config/lf/lfrc +Windows C:\[rs]ProgramData\[rs]lf\[rs]lfrc C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]lfrc +\f[R] +.fi .PP Colors file should be located at: -.PP -.EX - OS system-wide user-specific - Unix /etc/lf/colors ~/.config/lf/colors - Windows C:\eProgramData\elf\ecolors C:\eUsers\e\eAppData\eLocal\elf\ecolors -.EE +.IP +.nf +\f[C] +OS system\-wide user\-specific +Unix /etc/lf/colors \[ti]/.config/lf/colors +Windows C:\[rs]ProgramData\[rs]lf\[rs]colors C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]colors +\f[R] +.fi .PP Icons file should be located at: -.PP -.EX - OS system-wide user-specific - Unix /etc/lf/icons ~/.config/lf/icons - Windows C:\eProgramData\elf\eicons C:\eUsers\e\eAppData\eLocal\elf\eicons -.EE +.IP +.nf +\f[C] +OS system\-wide user\-specific +Unix /etc/lf/icons \[ti]/.config/lf/icons +Windows C:\[rs]ProgramData\[rs]lf\[rs]icons C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]icons +\f[R] +.fi .PP Selection file should be located at: -.PP -.EX - Unix ~/.local/share/lf/files - Windows C:\eUsers\e\eAppData\eLocal\elf\efiles -.EE +.IP +.nf +\f[C] +Unix \[ti]/.local/share/lf/files +Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]files +\f[R] +.fi .PP Marks file should be located at: -.PP -.EX - Unix ~/.local/share/lf/marks - Windows C:\eUsers\e\eAppData\eLocal\elf\emarks -.EE +.IP +.nf +\f[C] +Unix \[ti]/.local/share/lf/marks +Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]marks +\f[R] +.fi .PP Tags file should be located at: -.PP -.EX - Unix ~/.local/share/lf/tags - Windows C:\eUsers\e\eAppData\eLocal\elf\etags -.EE +.IP +.nf +\f[C] +Unix \[ti]/.local/share/lf/tags +Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]tags +\f[R] +.fi .PP History file should be located at: +.IP +.nf +\f[C] +Unix \[ti]/.local/share/lf/history +Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]history +\f[R] +.fi .PP -.EX - Unix ~/.local/share/lf/history - Windows C:\eUsers\e\eAppData\eLocal\elf\ehistory -.EE +You can configure these locations with the following variables given +with their order of precedences and their default values: +.IP +.nf +\f[C] +Unix + $LF_CONFIG_HOME + $XDG_CONFIG_HOME + \[ti]/.config + + $LF_DATA_HOME + $XDG_DATA_HOME + \[ti]/.local/share + +Windows + %ProgramData% + C:\[rs]ProgramData + + %LF_CONFIG_HOME% + %LOCALAPPDATA% + C:\[rs]Users\[rs]\[rs]AppData\[rs]Local +\f[R] +.fi .PP -You can configure these locations with the following variables given with their order of precedences and their default values: -.PP -.EX - Unix - $LF_CONFIG_HOME - $XDG_CONFIG_HOME - ~/.config -.EE -.PP -.EX - $LF_DATA_HOME - $XDG_DATA_HOME - ~/.local/share -.EE -.PP -.EX - Windows - %ProgramData% - C:\eProgramData -.EE -.PP -.EX - %LF_CONFIG_HOME% - %LOCALAPPDATA% - C:\eUsers\e\eAppData\eLocal -.EE -.PP -A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example +A sample configuration file can be found at +https://github.com/gokcehan/lf/blob/master/etc/lfrc.example (https://github.com/gokcehan/lf/blob/master/etc/lfrc.example) .SH COMMANDS -This section shows information about builtin commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings. .PP -.EX - quit (default 'q') -.EE +This section shows information about builtin commands. +Modal commands do not take any arguments, but instead change the +operation mode to read their input conveniently, and so they are meant +to be assigned to keybindings. +.SS quit (default \f[C]q\f[R]) .PP Quit lf and return to the shell. +.SS up (default \f[C]k\f[R] and \f[C]\f[R]), half\-up (default \f[C]\f[R]), page\-up (default \f[C]\f[R] and \f[C]\f[R]), scroll\-up (default \f[C]\f[R]), down (default \f[C]j\f[R] and \f[C]\f[R]), half\-down (default \f[C]\f[R]), page\-down (default \f[C]\f[R] and \f[C]\f[R]), scroll\-down (default \f[C]\f[R]) .PP -.EX - up (default 'k' and '') - half-up (default '') - page-up (default '' and '') - scroll-up (default '') - down (default 'j' and '') - half-down (default '') - page-down (default '' and '') - scroll-down (default '') -.EE -.PP -Move/scroll the current file selection upwards/downwards by one/half a page/full page. -.PP -.EX - updir (default 'h' and '') -.EE +Move/scroll the current file selection upwards/downwards by one/half a +page/full page. +.SS updir (default \f[C]h\f[R] and \f[C]\f[R]) .PP Change the current working directory to the parent directory. +.SS open (default \f[C]l\f[R] and \f[C]\f[R]) .PP -.EX - open (default 'l' and '') -.EE -.PP -If the current file is a directory, then change the current directory to it, otherwise, execute the 'open' command. A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument. A custom 'open' command can be defined to override this default. -.PP -.EX - jump-next (default ']') - jump-prev (default '[') -.EE +If the current file is a directory, then change the current directory to +it, otherwise, execute the \f[C]open\f[R] command. +A default \f[C]open\f[R] command is provided to call the default system +opener asynchronously with the current file as the argument. +A custom \f[C]open\f[R] command can be defined to override this default. +.SS jump\-next (default \f[C]]\f[R]), jump\-prev (default \f[C][\f[R]) .PP Change the current working directory to the next/previous jumplist item. +.SS top (default \f[C]gg\f[R] and \f[C]\f[R]), bottom (default \f[C]G\f[R] and \f[C]\f[R]) .PP -.EX - top (default 'gg' and '') - bottom (default 'G' and '') -.EE -.PP -Move the current file selection to the top/bottom of the directory. A count can be specified to move to a specific line, for example use `3G` to move to the third line. -.PP -.EX - high (default 'H') - middle (default 'M') - low (default 'L') -.EE +Move the current file selection to the top/bottom of the directory. +A count can be specified to move to a specific line, for example use +\f[C]3G\f[R] to move to the third line. +.SS high (default \f[C]H\f[R]), middle (default \f[C]M\f[R]), low (default \f[C]L\f[R]) .PP Move the current file selection to the high/middle/low of the screen. -.PP -.EX - toggle -.EE +.SS toggle .PP Toggle the selection of the current file or files given as arguments. +.SS invert (default \f[C]v\f[R]) .PP -.EX - invert (default 'v') -.EE +Reverse the selection of all files in the current directory (i.e. +\f[C]toggle\f[R] all files). +Selections in other directories are not effected by this command. +You can define a new command to select all files in the directory by +combining \f[C]invert\f[R] with \f[C]unselect\f[R] (i.e. +\f[C]cmd select\-all :unselect; invert\f[R]), though this will also +remove selections in other directories. +.SS invert\-below .PP -Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories. +Reverse the selection (i.e. +\f[C]toggle\f[R]) of all files at or after the current file in the +current directory. .PP -.EX - invert-below -.EE +To select a contiguous block of files, use this command on the first +file you want to select. +Then, move down to the first file you do \f[I]not\f[R] want to select +(the one after the end of the desired selection) and use this command +again. +This achieves an effect similar to the visual mode in vim. .PP -Reverse the selection (i.e. 'toggle') of all files at or after the current file in the current directory. -.PP -To select a contiguous block of files, use this command on the first file you want to select. Then, move down to the first file you do *not* want to select (the one after the end of the desired selection) and use this command again. This achieves an effect similar to the visual mode in vim. -.PP -This command is experimental and may be removed once a better replacement for the visual mode is implemented in 'lf'. If you'd like to experiment with using this command, you should bind it to a key (e.g. 'V') for a better experience. -.PP -.EX - unselect (default 'u') -.EE +This command is experimental and may be removed once a better +replacement for the visual mode is implemented in \f[C]lf\f[R]. +If you\[aq]d like to experiment with using this command, you should bind +it to a key (e.g. +\f[C]V\f[R]) for a better experience. +.SS unselect (default \f[C]u\f[R]) .PP Remove the selection of all files in all directories. -.PP -.EX - glob-select - glob-unselect -.EE +.SS glob\-select, glob\-unselect .PP Select/unselect files that match the given glob. +.SS calcdirsize .PP -.EX - calcdirsize -.EE +Calculate the total size for each of the selected directories. +Option \f[C]info\f[R] should include \f[C]size\f[R] and option +\f[C]dircounts\f[R] should be disabled to show this size. +If the total size of a directory is not calculated, it will be shown as +\f[C]\-\f[R]. +.SS clearmaps .PP -Calculate the total size for each of the selected directories. Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as '-'. +Remove all keybindings associated with the \f[C]map\f[R] command. +This command can be used in the config file to remove the default +keybindings. +For safety purposes, \f[C]:\f[R] is left mapped to the \f[C]read\f[R] +command, and \f[C]cmap\f[R] keybindings are retained so that it is still +possible to exit \f[C]lf\f[R] using \f[C]:quit\f[R]. +.SS copy (default \f[C]y\f[R]) .PP -.EX - clearmaps -.EE +If there are no selections, save the path of the current file to the +copy buffer, otherwise, copy the paths of selected files. +.SS cut (default \f[C]d\f[R]) .PP -Remove all keybindings associated with the `map` command. This command can be used in the config file to remove the default keybindings. For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`. +If there are no selections, save the path of the current file to the cut +buffer, otherwise, copy the paths of selected files. +.SS paste (default \f[C]p\f[R]) .PP -.EX - copy (default 'y') -.EE -.PP -If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files. -.PP -.EX - cut (default 'd') -.EE -.PP -If there are no selections, save the path of the current file to the cut buffer, otherwise, copy the paths of selected files. -.PP -.EX - paste (default 'p') -.EE -.PP -Copy/Move files in copy/cut buffer to the current working directory. A custom 'paste' command can be defined to override this default. -.PP -.EX - clear (default 'c') -.EE +Copy/Move files in copy/cut buffer to the current working directory. +A custom \f[C]paste\f[R] command can be defined to override this +default. +.SS clear (default \f[C]c\f[R]) .PP Clear file paths in copy/cut buffer. +.SS sync .PP -.EX - sync -.EE +Synchronize copied/cut files with server. +This command is automatically called when required. +.SS draw .PP -Synchronize copied/cut files with server. This command is automatically called when required. -.PP -.EX - draw -.EE -.PP -Draw the screen. This command is automatically called when required. -.PP -.EX - redraw (default '') -.EE +Draw the screen. +This command is automatically called when required. +.SS redraw (default \f[C]\f[R]) .PP Synchronize the terminal and redraw the screen. +.SS load .PP -.EX - load -.EE -.PP -Load modified files and directories. This command is automatically called when required. -.PP -.EX - reload (default '') -.EE +Load modified files and directories. +This command is automatically called when required. +.SS reload (default \f[C]\f[R]) .PP Flush the cache and reload all files and directories. -.PP -.EX - echo -.EE +.SS echo .PP Print given arguments to the message line at the bottom. +.SS echomsg .PP -.EX - echomsg -.EE +Print given arguments to the message line at the bottom and also to the +log file. +.SS echoerr .PP -Print given arguments to the message line at the bottom and also to the log file. -.PP -.EX - echoerr -.EE -.PP -Print given arguments to the message line at the bottom as 'errorfmt' and also to the log file. -.PP -.EX - cd -.EE +Print given arguments to the message line at the bottom as +\f[C]errorfmt\f[R] and also to the log file. +.SS cd .PP Change the working directory to the given argument. -.PP -.EX - select -.EE +.SS select .PP Change the current file selection to the given argument. +.SS delete (modal) .PP -.EX - delete (modal) -.EE +Remove the current file or selected file(s). +A custom \f[C]delete\f[R] command can be defined to override this +default. +.SS rename (modal) (default \f[C]r\f[R]) .PP -Remove the current file or selected file(s). A custom 'delete' command can be defined to override this default. -.PP -.EX - rename (modal) (default 'r') -.EE -.PP -Rename the current file using the builtin method. A custom 'rename' command can be defined to override this default. -.PP -.EX - source -.EE +Rename the current file using the builtin method. +A custom \f[C]rename\f[R] command can be defined to override this +default. +.SS source .PP Read the configuration file given in the argument. -.PP -.EX - push -.EE +.SS push .PP Simulate key pushes given in the argument. -.PP -.EX - read (modal) (default ':') -.EE +.SS read (modal) (default \f[C]:\f[R]) .PP Read a command to evaluate. -.PP -.EX - shell (modal) (default '$') -.EE +.SS shell (modal) (default \f[C]$\f[R]) .PP Read a shell command to execute. +.SS shell\-pipe (modal) (default \f[C]%\f[R]) .PP -.EX - shell-pipe (modal) (default '%') -.EE -.PP -Read a shell command to execute piping its standard I/O to the bottom statline. -.PP -.EX - shell-wait (modal) (default '!') -.EE +Read a shell command to execute piping its standard I/O to the bottom +statline. +.SS shell\-wait (modal) (default \f[C]!\f[R]) .PP Read a shell command to execute and wait for a key press in the end. -.PP -.EX - shell-async (modal) (default '&') -.EE +.SS shell\-async (modal) (default \f[C]&\f[R]) .PP Read a shell command to execute asynchronously without standard I/O. +.SS find (modal) (default \f[C]f\f[R]), find\-back (modal) (default \f[C]F\f[R]), find\-next (default \f[C];\f[R]), find\-prev (default \f[C],\f[R]) .PP -.EX - find (modal) (default 'f') - find-back (modal) (default 'F') - find-next (default ';') - find-prev (default ',') -.EE +Read key(s) to find the appropriate file name match in the +forward/backward direction and jump to the next/previous match. +.SS search (default \f[C]/\f[R]), search\-back (default \f[C]?\f[R]), search\-next (default \f[C]n\f[R]), search\-prev (default \f[C]N\f[R]) .PP -Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match. +Read a pattern to search for a file name match in the forward/backward +direction and jump to the next/previous match. +.SS filter (modal), setfilter .PP -.EX - search (default '/') - search-back (default '?') - search-next (default 'n') - search-prev (default 'N') -.EE -.PP -Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match. -.PP -.EX - filter (modal) - setfilter -.EE -.PP -Command 'filter' reads a pattern to filter out and only view files matching the pattern. Command 'setfilter' does the same but uses an argument to set the filter immediately. You can supply an argument to 'filter', in order to use that as the starting prompt. -.PP -.EX - mark-save (modal) (default 'm') -.EE +Command \f[C]filter\f[R] reads a pattern to filter out and only view +files matching the pattern. +Command \f[C]setfilter\f[R] does the same but uses an argument to set +the filter immediately. +You can supply an argument to \f[C]filter\f[R], in order to use that as +the starting prompt. +.SS mark\-save (modal) (default \f[C]m\f[R]) .PP Save the current directory as a bookmark assigned to the given key. +.SS mark\-load (modal) (default \f[C]\[aq]\f[R]) .PP -.EX - mark-load (modal) (default "'") -.EE -.PP -Change the current directory to the bookmark assigned to the given key. A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command. -.PP -.EX - mark-remove (modal) (default '"') -.EE +Change the current directory to the bookmark assigned to the given key. +A special bookmark \f[C]\[aq]\f[R] holds the previous directory after a +\f[C]mark\-load\f[R], \f[C]cd\f[R], or \f[C]select\f[R] command. +.SS mark\-remove (modal) (default \f[C]\[dq]\f[R]) .PP Remove a bookmark assigned to the given key. +.SS tag .PP -.EX - tag -.EE +Tag a file with \f[C]*\f[R] or a single width character given in the +argument. +You can define a new tag clearing command by combining \f[C]tag\f[R] +with \f[C]tag\-toggle\f[R] (i.e. +\f[C]cmd tag\-clear :tag; tag\-toggle\f[R]). +.SS tag\-toggle (default \f[C]t\f[R]) .PP -Tag a file with '*' or a single width character given in the argument. You can define a new tag clearing command by combining 'tag' with 'tag-toggle' (i.e. 'cmd tag-clear :tag; tag-toggle'). -.PP -.EX - tag-toggle (default 't') -.EE -.PP -Tag a file with '*' or a single width character given in the argument if the file is untagged, otherwise remove the tag. +Tag a file with \f[C]*\f[R] or a single width character given in the +argument if the file is untagged, otherwise remove the tag. .SH COMMAND LINE COMMANDS -The prompt character specifies which of the several command-line modes you are in. For example, the 'read' command takes you to the ':' mode. .PP -When the cursor is at the first character in ':' mode, pressing one of the keys '!', '$', '%', or '&' takes you to the corresponding mode. You can go back with 'cmd-delete-back' ('' by default). +The prompt character specifies which of the several command\-line modes +you are in. +For example, the \f[C]read\f[R] command takes you to the \f[C]:\f[R] +mode. .PP -The command line commands should be mostly compatible with readline keybindings. A character refers to a unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters. +When the cursor is at the first character in \f[C]:\f[R] mode, pressing +one of the keys \f[C]!\f[R], \f[C]$\f[R], \f[C]%\f[R], or \f[C]&\f[R] +takes you to the corresponding mode. +You can go back with \f[C]cmd\-delete\-back\f[R] (\f[C]\f[R] +by default). .PP -.EX - cmd-escape (default '') -.EE +The command line commands should be mostly compatible with readline +keybindings. +A character refers to a unicode code point, a word consists of letters +and digits, and a unix word consists of any non\-blank characters. +.SS cmd\-escape (default \f[C]\f[R]) .PP Quit command line mode and return to normal mode. -.PP -.EX - cmd-complete (default '') -.EE +.SS cmd\-complete (default \f[C]\f[R]) .PP Autocomplete the current word. +.SS cmd\-menu\-complete, cmd\-menu\-complete\-back .PP -.EX - cmd-menu-complete - cmd-menu-complete-back -.EE +Autocomplete the current word with menu selection. +You need to assign keys to these commands (e.g. +\f[C]cmap cmd\-menu\-complete; cmap cmd\-menu\-complete\-back\f[R]). +You can use the assigned keys assigned to display the menu and then +cycle through completion options. +.SS cmd\-menu\-accept .PP -Autocomplete the current word with menu selection. You need to assign keys to these commands (e.g. 'cmap cmd-menu-complete; cmap cmd-menu-complete-back'). You can use the assigned keys assigned to display the menu and then cycle through completion options. -.PP -.EX - cmd-menu-accept -.EE -.PP -Accept the currently selected match in menu completion and close the menu. -.PP -.EX - cmd-enter (default '' and '') -.EE +Accept the currently selected match in menu completion and close the +menu. +.SS cmd\-enter (default \f[C]\f[R] and \f[C]\f[R]) .PP Execute the current line. +.SS cmd\-interrupt (default \f[C]\f[R]) .PP -.EX - cmd-interrupt (default '') -.EE -.PP -Interrupt the current shell-pipe command and return to the normal mode. -.PP -.EX - cmd-history-next (default '' and '') - cmd-history-prev (default '' and '') -.EE +Interrupt the current shell\-pipe command and return to the normal mode. +.SS cmd\-history\-next (default \f[C]\f[R] and \f[C]\f[R]), cmd\-history\-prev (default \f[C]\f[R] and \f[C]\f[R]) .PP Go to next/previous item in the history. -.PP -.EX - cmd-left (default '' and '') - cmd-right (default '' and '') -.EE +.SS cmd\-left (default \f[C]\f[R] and \f[C]\f[R]), cmd\-right (default \f[C]\f[R] and \f[C]\f[R]) .PP Move the cursor to the left/right. -.PP -.EX - cmd-home (default '' and '') - cmd-end (default '' and '') -.EE +.SS cmd\-home (default \f[C]\f[R] and \f[C]\f[R]), cmd\-end (default \f[C]\f[R] and \f[C]\f[R]) .PP Move the cursor to the beginning/end of line. -.PP -.EX - cmd-delete (default '' and '') -.EE +.SS cmd\-delete (default \f[C]\f[R] and \f[C]\f[R]) .PP Delete the next character. +.SS cmd\-delete\-back (default \f[C]\f[R] and \f[C]\f[R]) .PP -.EX - cmd-delete-back (default '' and '') -.EE -.PP -Delete the previous character. When at the beginning of a prompt, returns either to normal mode or to ':' mode. -.PP -.EX - cmd-delete-home (default '') - cmd-delete-end (default '') -.EE +Delete the previous character. +When at the beginning of a prompt, returns either to normal mode or to +\f[C]:\f[R] mode. +.SS cmd\-delete\-home (default \f[C]\f[R]), cmd\-delete\-end (default \f[C]\f[R]) .PP Delete everything up to the beginning/end of line. -.PP -.EX - cmd-delete-unix-word (default '') -.EE +.SS cmd\-delete\-unix\-word (default \f[C]\f[R]) .PP Delete the previous unix word. -.PP -.EX - cmd-yank (default '') -.EE +.SS cmd\-yank (default \f[C]\f[R]) .PP Paste the buffer content containing the last deleted item. -.PP -.EX - cmd-transpose (default '') - cmd-transpose-word (default '') -.EE +.SS cmd\-transpose (default \f[C]\f[R]), cmd\-transpose\-word (default \f[C]\f[R]) .PP Transpose the positions of last two characters/words. -.PP -.EX - cmd-word (default '') - cmd-word-back (default '') -.EE +.SS cmd\-word (default \f[C]\f[R]), cmd\-word\-back (default \f[C]\f[R]) .PP Move the cursor by one word in forward/backward direction. -.PP -.EX - cmd-delete-word (default '') -.EE +.SS cmd\-delete\-word (default \f[C]\f[R]) .PP Delete the next word in forward direction. -.PP -.EX - cmd-delete-word-back (default '' and '') -.EE +.SS cmd\-delete\-word\-back (default \f[C]\f[R] and \f[C]\f[R]) .PP Delete the previous word in backward direction. +.SS cmd\-capitalize\-word (default \f[C]\f[R]), cmd\-uppercase\-word (default \f[C]\f[R]), cmd\-lowercase\-word (default \f[C]\f[R]) .PP -.EX - cmd-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') -.EE -.PP -Capitalize/uppercase/lowercase the current word and jump to the next word. +Capitalize/uppercase/lowercase the current word and jump to the next +word. .SH OPTIONS -This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'. .PP -.EX - anchorfind bool (default true) -.EE +This section shows information about options to customize the behavior. +Character \f[C]:\f[R] is used as the separator for list options +\f[C][]int\f[R] and \f[C][]string\f[R]. +.SS anchorfind (bool) (default true) .PP -When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position. -.PP -.EX - autoquit bool (default false) -.EE +When this option is enabled, find command starts matching patterns from +the beginning of file names, otherwise, it can match at an arbitrary +position. +.SS autoquit (bool) (default false) .PP Automatically quit server when there are no clients left connected. +.SS borderfmt (string) (default \f[C]\[rs]033[0m\f[R]) .PP -.EX - borderfmt string (default "\e033[0m") -.EE +Format string of the box drawing characters enabled by the +\f[C]drawbox\f[R] option. +.SS cleaner (string) (default \[ga]\[ga]) (not called if empty) .PP -Format string of the box drawing characters enabled by the `drawbox` option. +Set the path of a cleaner file. +The file should be executable. +This file is called if previewing is enabled, the previewer is set, and +the previously selected file had its preview cache disabled. +The following arguments are passed to the file, (1) current file name, +(2) width, (3) height, (4) horizontal position, (5) vertical position of +preview pane and (6) next file name to be previewed respectively. +Preview cleaning is disabled when the value of this option is left +empty. +.SS cursoractivefmt (string) (default \f[C]\[rs]033[7m\f[R]), cursorparentfmt string (default \f[C]\[rs]033[7m\f[R]), cursorpreviewfmt string (default \f[C]\[rs]033[4m\f[R]) .PP -.EX - cleaner string (default '') (not called if empty) -.EE +Format strings for highlighting the cursor. +\f[C]cursoractivefmt\f[R] applies in the current directory pane, +\f[C]cursorparentfmt\f[R] applies in panes that show parents of the +current directory, and \f[C]cursorpreviewfmt\f[R] applies in panes that +preview directories. .PP -Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively. Preview cleaning is disabled when the value of this option is left empty. +The default is to make the active cursor and the parent directory cursor +inverted. +The preview cursor is underlined. .PP -.EX - cursoractivefmt string (default "\e033[7m") - cursorparentfmt string (default "\e033[7m") - cursorpreviewfmt string (default "\e033[4m") -.EE +Some other possibilities to consider for the preview or parent cursors: +an empty string for no cursor, \f[C]\[rs]033[7;2m\f[R] for dimmed +inverted text (visibility varies by terminal), \f[C]\[rs]033[7;90m\f[R] +for inverted text with grey (aka \[dq]brightblack\[dq]) background. .PP -Format strings for highlighting the cursor. `cursoractivefmt` applies in the current directory pane, `cursorparentfmt` applies in panes that show parents of the current directory, and `cursorpreviewfmt` applies in panes that preview directories. -.PP -The default is to make the active cursor and the parent directory cursor inverted. The preview cursor is underlined. -.PP -Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, "\e033[7;2m" for dimmed inverted text (visibility varies by terminal), "\e033[7;90m" for inverted text with grey (aka "brightblack") background. -.PP -If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m". -.PP -.EX - dircache bool (default true) -.EE +If the format string contains the characters \f[C]%s\f[R], it is +interpreted as a format string for \f[C]fmt.Sprintf\f[R]. +Such a string should end with the terminal reset sequence. +For example, \f[C]\[rs]033[4m%s\[rs]033[0m\f[R] has the same effect as +\f[C]\[rs]033[4m\f[R]. +.SS dircache (bool) (default true) .PP Cache directory contents. +.SS dircounts (bool) (default false) .PP -.EX - dircounts bool (default false) -.EE -.PP -When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using 'calcdirsize'. This information needs to be calculated by reading the directory and counting the items inside. Therefore, this option is disabled by default for performance reasons. This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. 999 items are counted per directory at most, and bigger directories are shown as '999+'. -.PP -.EX - dirfirst bool (default true) -.EE +When this option is enabled, directory sizes show the number of items +inside instead of the total size of the directory, which needs to be +calculated for each directory using \f[C]calcdirsize\f[R]. +This information needs to be calculated by reading the directory and +counting the items inside. +Therefore, this option is disabled by default for performance reasons. +This option only has an effect when \f[C]info\f[R] has a \f[C]size\f[R] +field and the pane is wide enough to show the information. +999 items are counted per directory at most, and bigger directories are +shown as \f[C]999+\f[R]. +.SS dirfirst (bool) (default true) .PP Show directories first above regular files. -.PP -.EX - dironly bool (default false) -.EE +.SS dironly (bool) (default false) .PP Show only directories. +.SS dirpreviews (bool) (default false) .PP -.EX - dirpreviews bool (default false) -.EE -.PP -If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. -.PP -.EX - drawbox bool (default false) -.EE +If enabled, directories will also be passed to the previewer script. +This allows custom previews for directories. +.SS drawbox (bool) (default false) .PP Draw boxes around panes with box drawing characters. +.SS dupfilefmt (string) (default \f[C]%f.\[ti]%n\[ti]\f[R]) .PP -.EX - dupfilefmt string (default '%f.~%n~') -.EE -.PP -Format string of file name when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`. Special expansions are provided, '%f' as the file name, '%b' for basename (file name without extension), '%e' as the extension (including the dot) and '%n' as the number of duplicates. -.PP -.EX - errorfmt string (default "\e033[7;31;47m") -.EE +Format string of file name when creating duplicate files. +With the default format, copying a file \f[C]abc.txt\f[R] to the same +directory will result in a duplicate file called +\f[C]abc.txt.\[ti]1\[ti]\f[R]. +Special expansions are provided, \f[C]%f\f[R] as the file name, +\f[C]%b\f[R] for basename (file name without extension), \f[C]%e\f[R] as +the extension (including the dot) and \f[C]%n\f[R] as the number of +duplicates. +.SS errorfmt (string) (default \f[C]\[rs]033[7;31;47m\f[R]) .PP Format string of error messages shown in the bottom message line. .PP -If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m". +If the format string contains the characters \f[C]%s\f[R], it is +interpreted as a format string for \f[C]fmt.Sprintf\f[R]. +Such a string should end with the terminal reset sequence. +For example, \f[C]\[rs]033[4m%s\[rs]033[0m\f[R] has the same effect as +\f[C]\[rs]033[4m\f[R]. +.SS filesep (string) (default \f[C]\[rs]n\f[R]) .PP -.EX - filesep string (default "\en") -.EE +File separator used in environment variables \f[C]fs\f[R] and +\f[C]fx\f[R]. +.SS findlen (int) (default 1) .PP -File separator used in environment variables 'fs' and 'fx'. +Number of characters prompted for the find command. +When this value is set to 0, find command prompts until there is only a +single match left. +.SS globsearch (bool) (default false) .PP -.EX - findlen int (default 1) -.EE +When this option is enabled, search command patterns are considered as +globs, otherwise they are literals. +With globbing, \f[C]*\f[R] matches any sequence, \f[C]?\f[R] matches any +character, and \f[C][...]\f[R] or \f[C][\[ha]...]\f[R] matches character +sets or ranges. +Otherwise, these characters are interpreted as they are. +.SS hidden (bool) (default false) .PP -Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left. +Show hidden files. +On Unix systems, hidden files are determined by the value of +\f[C]hiddenfiles\f[R]. +On Windows, only files with hidden attributes are considered hidden +files. +.SS hiddenfiles ([]string) (default \f[C].*\f[R]) .PP -.EX - globsearch bool (default false) -.EE -.PP -When this option is enabled, search command patterns are considered as globs, otherwise they are literals. With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...]' matches character sets or ranges. Otherwise, these characters are interpreted as they are. -.PP -.EX - hidden bool (default false) -.EE -.PP -Show hidden files. On Unix systems, hidden files are determined by the value of 'hiddenfiles'. On Windows, only files with hidden attributes are considered hidden files. -.PP -.EX - hiddenfiles []string (default '.*') -.EE -.PP -List of hidden file glob patterns. Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...]' to match character sets or ranges. In addition, if a pattern starts with '!', then its matches are excluded from hidden files. To add multiple patterns, use ':' as a separator. Example: '.*:lost+found:*.bak' -.PP -.EX - history bool (default true) -.EE +List of hidden file glob patterns. +Patterns can be given as relative or absolute paths. +Globbing supports the usual special characters, \f[C]*\f[R] to match any +sequence, \f[C]?\f[R] to match any character, and \f[C][...]\f[R] or +\f[C][\[ha]...]\f[R] to match character sets or ranges. +In addition, if a pattern starts with \f[C]!\f[R], then its matches are +excluded from hidden files. +To add multiple patterns, use \f[C]:\f[R] as a separator. +Example: \f[C].*:lost+found:*.bak\f[R] +.SS history (bool) (default true) .PP Save command history. -.PP -.EX - icons bool (default false) -.EE +.SS icons (bool) (default false) .PP Show icons before each item in the list. +.SS ifs (string) (default \[ga]\[ga]) .PP -.EX - ifs string (default '') -.EE -.PP -Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as "IFS='...'; ...". The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on Windows. -.PP -.EX - ignorecase bool (default true) -.EE +Sets \f[C]IFS\f[R] variable in shell commands. +It works by adding the assignment to the beginning of the command string +as \f[C]IFS=...; ...\f[R]. +The reason is that \f[C]IFS\f[R] variable is not inherited by the shell +for security reasons. +This method assumes a POSIX shell syntax and so it can fail for +non\-POSIX shells. +This option has no effect when the value is left empty. +This option does not have any effect on Windows. +.SS ignorecase (bool) (default true) .PP Ignore case in sorting and search patterns. -.PP -.EX - ignoredia bool (default true) -.EE +.SS ignoredia (bool) (default true) .PP Ignore diacritics in sorting and search patterns. -.PP -.EX - incsearch bool (default false) -.EE +.SS incsearch (bool) (default false) .PP Jump to the first match after each keystroke during searching. -.PP -.EX - incfilter bool (default false) -.EE +.SS incfilter (bool) (default false) .PP Apply filter pattern after each keystroke during filtering. +.SS info ([]string) (default \[ga]\[ga]) .PP -.EX - info []string (default '') -.EE +List of information shown for directory items at the right side of pane. +Currently supported information types are \f[C]size\f[R], +\f[C]time\f[R], \f[C]atime\f[R], and \f[C]ctime\f[R]. +Information is only shown when the pane width is more than twice the +width of information. +.SS infotimefmtnew (string) (default \f[C]Jan _2 15:04\f[R]) .PP -List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information. +Format string of the file time shown in the info column when it matches +this year. +.SS infotimefmtold (string) (default \f[C]Jan _2 2006\f[R]) .PP -.EX - infotimefmtnew string (default 'Jan _2 15:04') -.EE -.PP -Format string of the file time shown in the info column when it matches this year. -.PP -.EX - infotimefmtold string (default 'Jan _2 2006') -.EE -.PP -Format string of the file time shown in the info column when it doesn't match this year. -.PP -.EX - mouse bool (default false) -.EE +Format string of the file time shown in the info column when it +doesn\[aq]t match this year. +.SS mouse (bool) (default false) .PP Send mouse events as input. +.SS number (bool) (default false) .PP -.EX - number bool (default false) -.EE -.PP -Show the position number for directory items at the left side of pane. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. -.PP -.EX - numberfmt string (default "\e033[33m") -.EE +Show the position number for directory items at the left side of pane. +When \f[C]relativenumber\f[R] option is enabled, only the current line +shows the absolute position and relative positions are shown for the +rest. +.SS numberfmt (string) (default \f[C]\[rs]033[33m\f[R]) .PP Format string of the position number for each line. +.SS period (int) (default 0) .PP -.EX - period int (default 0) -.EE +Set the interval in seconds for periodic checks of directory updates. +This works by periodically calling the \f[C]load\f[R] command. +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. +Periodic checks are disabled when the value of this option is set to +zero. +.SS preserve ([]string) (default \f[C]mode\f[R]) .PP -Set the interval in seconds for periodic checks of directory updates. This works by periodically calling the 'load' command. 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. Periodic checks are disabled when the value of this option is set to zero. +List of attributes that are preserved when copying files. +Currently supported attributes are \f[C]mode\f[R] (i.a. +access mode) and \f[C]timestamps\f[R] (i.e. +modification time and access time). +Note, preserving other attribute like ownership of change/birth +timestamp is desirable, but not portably supported in Go. +.SS preview (bool) (default true) .PP -.EX - preserve []string (default 'mode') -.EE +Show previews of files and directories at the right most pane. +If the file has more lines than the preview pane, rest of the lines are +not read. +Files containing the null character (U+0000) in the read portion are +considered binary files and displayed as \f[C]binary\f[R]. +.SS previewer (string) (default \[ga]\[ga]) (not filtered if empty) .PP -List of attributes that are preserved when copying files. Currently supported attributes are 'mode' (i.a. access mode) and 'timestamps' (i.e. modification time and access time). Note, preserving other attribute like ownership of change/birth timestamp is desirable, but not portably supported in Go. +Set the path of a previewer file to filter the content of regular files +for previewing. +The file should be executable. +The following arguments are passed to the file, (1) current file name, +(2) width, (3) height, (4) horizontal position, and (5) vertical +position of preview pane respectively. +SIGPIPE signal is sent when enough lines are read. +If the previewer returns a non\-zero exit code, then the preview cache +for the given file is disabled. +This means that if the file is selected in the future, the previewer is +called once again. +Preview filtering is disabled and files are displayed as they are when +the value of this option is left empty. +.SS promptfmt (string) (default \f[C]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f\[rs]033[0m\f[R]) .PP -.EX - preview bool (default true) -.EE +Format string of the prompt shown in the top line. +Special expansions are provided, \f[C]%u\f[R] as the user name, +\f[C]%h\f[R] as the host name, \f[C]%w\f[R] as the working directory, +\f[C]%d\f[R] as the working directory with a trailing path separator, +\f[C]%f\f[R] as the file name, and \f[C]%F\f[R] as the current filter. +\f[C]%S\f[R] may be used once and will provide a spacer so that the +following parts are right aligned on the screen. +Home folder is shown as \f[C]\[ti]\f[R] in the working directory +expansion. +Directory names are automatically shortened to a single character +starting from the left most parent when the prompt does not fit to the +screen. +.SS ratios ([]int) (default \f[C]1:2:3\f[R]) .PP -Show previews of files and directories at the right most pane. If the file has more lines than the preview pane, rest of the lines are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as 'binary'. +List of ratios of pane widths. +Number of items in the list determines the number of panes in the ui. +When \f[C]preview\f[R] option is enabled, the right most number is used +for the width of preview pane. +.SS relativenumber (bool) (default false) .PP -.EX - previewer string (default '') (not filtered if empty) -.EE -.PP -Set the path of a previewer file to filter the content of regular files for previewing. The file should be executable. The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. SIGPIPE signal is sent when enough lines are read. If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. This means that if the file is selected in the future, the previewer is called once again. Preview filtering is disabled and files are displayed as they are when the value of this option is left empty. -.PP -.EX - promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m") -.EE -.PP -Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen. -.PP -.EX - ratios []int (default '1:2:3') -.EE -.PP -List of ratios of pane widths. Number of items in the list determines the number of panes in the ui. When 'preview' option is enabled, the right most number is used for the width of preview pane. -.PP -.EX - relativenumber bool (default false) -.EE -.PP -Show the position number relative to the current line. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown. -.PP -.EX - reverse bool (default false) -.EE +Show the position number relative to the current line. +When \f[C]number\f[R] is enabled, current line shows the absolute +position, otherwise nothing is shown. +.SS reverse (bool) (default false) .PP Reverse the direction of sort. +.SS ruler ([]string) (default \f[C]acc:progress:selection:filter:ind\f[R]) .PP -.EX - ruler []string (default 'acc:progress:selection:filter:ind') -.EE +This option is deprecated in favor of using the \f[C]rulerfmt\f[R] +option (see below). +List of information shown in status line ruler. +Currently supported information types are \f[C]acc\f[R], +\f[C]progress\f[R], \f[C]selection\f[R], \f[C]filter\f[R], +\f[C]ind\f[R], \f[C]df\f[R] and names starting with \f[C]lf_\f[R]. +\f[C]acc\f[R] shows the pressed keys (e.g. +for bindings with multiple key presses or counts given to bindings). +\f[C]progress\f[R] shows the progress of file operations (e.g. +copying a large directory). +\f[C]selection\f[R] shows the number of files that are selected, or +designated for being cut/copied. +\f[C]filter\f[R] shows \f[C]F\f[R] if a filter is currently being +applied. +\f[C]ind\f[R] shows the current position of the cursor as well as the +number of files in the current directory. +\f[C]df\f[R] shows the amount of free disk space remaining. +Names starting with \f[C]lf_\f[R] show the value of environment +variables exported by lf. +This is useful for displaying the current settings (e.g. +\f[C]lf_selmode\f[R] displays the current setting for the +\f[C]selmode\f[R] option). +User defined options starting with \f[C]lf_user_\f[R] are also +supported, so it is possible to display information set from external +sources. +.SS rulerfmt (string) (default \f[C] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\f[R]) .PP -This option is deprecated in favor of using the `rulerfmt` option (see below). List of information shown in status line ruler. Currently supported information types are 'acc', 'progress', 'selection', 'filter', 'ind', 'df' and names starting with 'lf_'. `acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings). `progress` shows the progress of file operations (e.g. copying a large directory). `selection` shows the number of files that are selected, or designated for being cut/copied. `filter` shows 'F' if a filter is currently being applied. `ind` shows the current position of the cursor as well as the number of files in the current directory. `df` shows the amount of free disk space remaining. Names starting with `lf_` show the value of environment variables exported by lf. This is useful for displaying the current settings (e.g. `lf_selmode` displays the current setting for the `selmode` option). User defined options starting with `lf_user_` are also supported, so it is possible to display information set from external sources. +Format string of the ruler shown in the bottom right corner. +Special expansions are provided, \f[C]%a\f[R] as the pressed keys, +\f[C]%p\f[R] as the progress of file operations, \f[C]%m\f[R] as the +number of files to be cut (moved), \f[C]%c\f[R] as the number of files +to be copied, \f[C]%s\f[R] as the number of selected files, \f[C]%f\f[R] +as the filter, \f[C]%i\f[R] as the position of the cursor, \f[C]%t\f[R] +as the number of files shown in the current directory, \f[C]%h\f[R] as +the number of files hidden in the current directory, and \f[C]%d\f[R] as +the amount of free disk space remaining. +Additional expansions are provided for environment variables exported by +lf, in the form \f[C]%{lf_}\f[R] (e.g. +\f[C]%{lf_selmode}\f[R]). +This is useful for displaying the current settings. +Expansions are also provided for user defined options, in the form +\f[C]%{lf_user_}\f[R] (e.g. +\f[C]%{lf_user_foo}\f[R]). +The \f[C]|\f[R] character splits the format string into sections. +Any section containing a failed expansion (result is a blank string) is +discarded and not shown. +.SS selmode (string) (default \f[C]all\f[R]) .PP -.EX - rulerfmt string (default " %a| %p| \e033[7;31m %m \e033[0m| \e033[7;33m %c \e033[0m| \e033[7;35m %s \e033[0m| \e033[7;34m %f \e033[0m| %i/%t") -.EE +Selection mode for commands. +When set to \f[C]all\f[R] it will use the selected files from all +directories. +When set to \f[C]dir\f[R] it will only use the selected files in the +current directory. +.SS scrolloff (int) (default 0) .PP -Format string of the ruler shown in the bottom right corner. Special expansions are provided, '%a' as the pressed keys, '%p' as the progress of file operations, '%m' as the number of files to be cut (moved), '%c' as the number of files to be copied, '%s' as the number of selected files, '%f' as the filter, '%i' as the position of the cursor, '%t' as the number of files shown in the current directory, '%h' as the number of files hidden in the current directory, and '%d' as the amount of free disk space remaining. Additional expansions are provided for environment variables exported by lf, in the form `%{lf_}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings. Expansions are also provided for user defined options, in the form `%{lf_user_}` (e.g. `%{lf_user_foo}`). The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. +Minimum number of offset lines shown at all times in the top and the +bottom of the screen when scrolling. +The current line is kept in the middle when this option is set to a +large value that is bigger than the half of number of lines. +A smaller offset can be used when the current file is close to the +beginning or end of the list to show the maximum number of items. +.SS shell (string) (default \f[C]sh\f[R] for Unix and \f[C]cmd\f[R] for Windows) .PP -.EX - selmode string (default 'all') -.EE -.PP -Selection mode for commands. When set to 'all' it will use the selected files from all directories. When set to 'dir' it will only use the selected files in the current directory. -.PP -.EX - scrolloff int (default 0) -.EE -.PP -Minimum number of offset lines shown at all times in the top and the bottom of the screen when scrolling. The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items. -.PP -.EX - shell string (default 'sh' for Unix and 'cmd' for Windows) -.EE -.PP -Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'. -.PP -.EX - shellflag string (default '-c' for Unix and '/c' for Windows) -.EE +Shell executable to use for shell commands. +Shell commands are executed as +\f[C]shell shellopts shellflag command \-\- arguments\f[R]. +.SS shellflag (string) (default \f[C]\-c\f[R] for Unix and \f[C]/c\f[R] for Windows) .PP Command line flag used to pass shell commands. -.PP -.EX - shellopts []string (default '') -.EE +.SS shellopts ([]string) (default \[ga]\[ga]) .PP List of shell options to pass to the shell executable. -.PP -.EX - sixel bool (default false) -.EE +.SS sixel (bool) (default false) .PP Render sixel images in preview. +.SS smartcase (bool) (default true) .PP -.EX - smartcase bool (default true) -.EE +Override \f[C]ignorecase\f[R] option when the pattern contains an +uppercase character. +This option has no effect when \f[C]ignorecase\f[R] is disabled. +.SS smartdia (bool) (default false) .PP -Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled. +Override \f[C]ignoredia\f[R] option when the pattern contains a +character with diacritic. +This option has no effect when \f[C]ignoredia\f[R] is disabled. +.SS sortby (string) (default \f[C]natural\f[R]) .PP -.EX - smartdia bool (default false) -.EE +Sort type for directories. +Currently supported sort types are \f[C]natural\f[R], \f[C]name\f[R], +\f[C]size\f[R], \f[C]time\f[R], \f[C]ctime\f[R], \f[C]atime\f[R], and +\f[C]ext\f[R]. +.SS statfmt (string) (default \f[C]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| \-> %l\f[R]) .PP -Override 'ignoredia' option when the pattern contains a character with diacritic. This option has no effect when 'ignoredia' is disabled. +Format string of the file info shown in the bottom left corner. +Special expansions are provided, \f[C]%p\f[R] as the file permissions, +\f[C]%c\f[R] as the link count, \f[C]%u\f[R] as the user, \f[C]%g\f[R] +as the group, \f[C]%s\f[R] as the file size, \f[C]%S\f[R] as the file +size but with a fixed width of four characters (left\-padded with +spaces), \f[C]%t\f[R] as the last modified time, and \f[C]%l\f[R] as the +link target. +The \f[C]|\f[R] character splits the format string into sections. +Any section containing a failed expansion (result is a blank string) is +discarded and not shown. +.SS tabstop (int) (default 8) .PP -.EX - sortby string (default 'natural') -.EE -.PP -Sort type for directories. Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', 'atime', and 'ext'. -.PP -.EX - statfmt string (default "\e033[36m%p\e033[0m| %c| %u| %g| %S| %t| -> %l") -.EE -.PP -Format string of the file info shown in the bottom left corner. Special expansions are provided, '%p' as the file permissions, '%c' as the link count, '%u' as the user, '%g' as the group, '%s' as the file size, '%S' as the file size but with a fixed width of four characters (left-padded with spaces), '%t' as the last modified time, and '%l' as the link target. The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. -.PP -.EX - tabstop int (default 8) -.EE -.PP -Number of space characters to show for horizontal tabulation (U+0009) character. -.PP -.EX - tagfmt string (default "\e033[31m") -.EE +Number of space characters to show for horizontal tabulation (U+0009) +character. +.SS tagfmt (string) (default \f[C]\[rs]033[31m\f[R]) .PP Format string of the tags. .PP -If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m". +If the format string contains the characters \f[C]%s\f[R], it is +interpreted as a format string for \f[C]fmt.Sprintf\f[R]. +Such a string should end with the terminal reset sequence. +For example, \f[C]\[rs]033[4m%s\[rs]033[0m\f[R] has the same effect as +\f[C]\[rs]033[4m\f[R]. +.SS tempmarks (string) (default \[ga]\[ga]) .PP -.EX - tempmarks string (default '') -.EE -.PP -Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c'). These marks are not synced to other clients and they are not saved in the bookmarks file. Note that the special bookmark "'" is always treated as temporary and it does not need to be specified. -.PP -.EX - timefmt string (default 'Mon Jan _2 15:04:05 2006') -.EE +Marks to be considered temporary (e.g. +\f[C]abc\f[R] refers to marks \f[C]a\f[R], \f[C]b\f[R], and +\f[C]c\f[R]). +These marks are not synced to other clients and they are not saved in +the bookmarks file. +Note that the special bookmark \f[C]\[ga]\f[R] is always treated as +temporary and it does not need to be specified. +.SS timefmt (string) (default \f[C]Mon Jan _2 15:04:05 2006\f[R]) .PP Format string of the file modification time shown in the bottom line. +.SS truncatechar (string) (default \f[C]\[ti]\f[R]) .PP -.EX - truncatechar string (default '~') -.EE +Truncate character shown at the end when the file name does not fit to +the pane. +.SS truncatepct (int) (default 100) .PP -Truncate character shown at the end when the file name does not fit to the pane. +When a filename is too long to be shown completely, the available space +is partitioned in two pieces. +truncatepct defines a fraction (in percent between 0 and 100) for the +size of the first piece, which will show the beginning of the filename. +The second piece will show the end of the filename and will use the rest +of the available space. +Both pieces are separated by the truncation character (truncatechar). +A value of 100 will only show the beginning of the filename, while a +value of 0 will only show the end of the filename, e.g.: +.IP \[bu] 2 +\f[C]set truncatepct 100\f[R] \-> +\f[C]very\-long\-filename\-tr\[ti]\f[R] (default) +.IP \[bu] 2 +\f[C]set truncatepct 50\f[R] \-> \f[C]very\-long\-f\[ti]\-truncated\f[R] +.IP \[bu] 2 +\f[C]set truncatepct 0\f[R] \-> \f[C]\[ti]ng\-filename\-truncated\f[R] +.SS waitmsg (string) (default \f[C]Press any key to continue\f[R]) .PP -.EX - truncatepct int (default 100) -.EE -.PP -When a filename is too long to be shown completely, the available space is partitioned in two pieces. truncatepct defines a fraction (in percent between 0 and 100) for the size of the first piece, which will show the beginning of the filename. The second piece will show the end of the filename and will use the rest of the available space. Both pieces are separated by the truncation character (truncatechar). A value of 100 will only show the beginning of the filename, while a value of 0 will only show the end of the filename, e.g.: -.PP -- `set truncatepct 100` -> "very-long-filename-tr~" (default) -.PP -- `set truncatepct 50` -> "very-long-f~-truncated" -.PP -- `set truncatepct 0` -> "~ng-filename-truncated" -.PP -.EX - waitmsg string (default 'Press any key to continue') -.EE -.PP -String shown after commands of shell-wait type. -.PP -.EX - wrapscan bool (default true) -.EE +String shown after commands of shell\-wait type. +.SS wrapscan (bool) (default true) .PP Searching can wrap around the file list. -.PP -.EX - wrapscroll bool (default false) -.EE +.SS wrapscroll (bool) (default false) .PP Scrolling can wrap around the file list. +.SS user_{option} (string) (default none) .PP -.EX - user_{option} string (default none) -.EE -.PP -Any option that is prefixed with 'user_' is a user defined option and can be set to any string. Inside a user defined command the value will be provided in the `lf_user_{option}` environment variable. These options are not used by lf and are not persisted. +Any option that is prefixed with \f[C]user_\f[R] is a user defined +option and can be set to any string. +Inside a user defined command the value will be provided in the +\f[C]lf_user_{option}\f[R] environment variable. +These options are not used by lf and are not persisted. .SH ENVIRONMENT VARIABLES -The following variables are exported for shell commands: These are referred with a '$' prefix on POSIX shells (e.g. '$f'), between '%' characters on Windows cmd (e.g. '%f%'), and with a '$env:' prefix on Windows powershell (e.g. '$env:f'). .PP -.EX - f -.EE +The following variables are exported for shell commands: These are +referred with a \f[C]$\f[R] prefix on POSIX shells (e.g. +\f[C]$f\f[R]), between \f[C]%\f[R] characters on Windows cmd (e.g. +\f[C]%f%\f[R]), and with a \f[C]$env:\f[R] prefix on Windows powershell +(e.g. +\f[C]$env:f\f[R]). +.SS f .PP Current file selection as a full path. +.SS fs .PP -.EX - fs -.EE +Selected file(s) separated with the value of \f[C]filesep\f[R] option as +full path(s). +.SS fx .PP -Selected file(s) separated with the value of 'filesep' option as full path(s). -.PP -.EX - fx -.EE -.PP -Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current file selection (i.e. 'f'). -.PP -.EX - id -.EE +Selected file(s) (i.e. +\f[C]fs\f[R]) if there are any selected files, otherwise current file +selection (i.e. +\f[C]f\f[R]). +.SS id .PP Id of the running client. -.PP -.EX - PWD -.EE +.SS PWD .PP Present working directory. -.PP -.EX - OLDPWD -.EE +.SS OLDPWD .PP Initial working directory. +.SS LF_LEVEL .PP -.EX - LF_LEVEL -.EE +The value of this variable is set to the current nesting level when you +run lf from a shell spawned inside lf. +You can add the value of this variable to your shell prompt to make it +clear that your shell runs inside lf. +For example, with POSIX shells, you can use +\f[C][ \-n \[dq]$LF_LEVEL\[dq] ] && PS1=\[dq]$PS1\[dq]\[dq](lf level: $LF_LEVEL) \[dq]\f[R] +in your shell configuration file (e.g. +\f[C]\[ti]/.bashrc\f[R]). +.SS OPENER .PP -The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf. You can add the value of this variable to your shell prompt to make it clear that your shell runs inside lf. For example, with POSIX shells, you can use '[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc'). +If this variable is set in the environment, use the same value. +Otherwise, this is set to \f[C]start\f[R] in Windows, \f[C]open\f[R] in +MacOS, \f[C]xdg\-open\f[R] in others. +.SS EDITOR .PP -.EX - OPENER -.EE +If VISUAL is set in the environment, use its value. +Otherwise, use the value of the environment variable EDITOR. +If neither variable is set, this is set to \f[C]vi\f[R] on Unix, +\f[C]notepad\f[R] in Windows. +.SS PAGER .PP -If this variable is set in the environment, use the same value. Otherwise, this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value. +Otherwise, this is set to \f[C]less\f[R] on Unix, \f[C]more\f[R] in +Windows. +.SS SHELL .PP -.EX - EDITOR -.EE +If this variable is set in the environment, use the same value. +Otherwise, this is set to \f[C]sh\f[R] on Unix, \f[C]cmd\f[R] in +Windows. +.SS lf .PP -If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows. -.PP -.EX - PAGER -.EE -.PP -If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows. -.PP -.EX - SHELL -.EE -.PP -If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows. -.PP -.EX - lf -.EE -.PP -Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'. -.PP -.EX - lf_{option} -.EE +Absolute path to the currently running lf binary, if it can be found. +Otherwise, this is set to the string \f[C]lf\f[R]. +.SS lf_{option} .PP Value of the {option}. -.PP -.EX - lf_user_{option} -.EE +.SS lf_user_{option} .PP Value of the user_{option}. -.PP -.EX - lf_width - lf_height -.EE +.SS lf_width, lf_height .PP Width/Height of the terminal. -.PP -.EX - lf_count -.EE +.SS lf_count .PP Value of the count associated with the current command. .SH SPECIAL COMMANDS +.PP This section shows information about special shell commands. +.SS open .PP -.EX - open -.EE +This shell command can be defined to override the default \f[C]open\f[R] +command when the current file is not a directory. +.SS paste .PP -This shell command can be defined to override the default 'open' command when the current file is not a directory. +This shell command can be defined to override the default +\f[C]paste\f[R] command. +.SS rename .PP -.EX - paste -.EE +This shell command can be defined to override the default +\f[C]rename\f[R] command. +.SS delete .PP -This shell command can be defined to override the default 'paste' command. +This shell command can be defined to override the default +\f[C]delete\f[R] command. +.SS pre\-cd .PP -.EX - rename -.EE +This shell command can be defined to be executed before changing a +directory. +.SS on\-cd .PP -This shell command can be defined to override the default 'rename' command. +This shell command can be defined to be executed after changing a +directory. +.SS on\-select .PP -.EX - delete -.EE +This shell command can be defined to be executed after the selection +changes. +.SS on\-redraw .PP -This shell command can be defined to override the default 'delete' command. -.PP -.EX - pre-cd -.EE -.PP -This shell command can be defined to be executed before changing a directory. -.PP -.EX - on-cd -.EE -.PP -This shell command can be defined to be executed after changing a directory. -.PP -.EX - on-select -.EE -.PP -This shell command can be defined to be executed after the selection changes. -.PP -.EX - on-redraw -.EE -.PP -This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized. -.PP -.EX - on-quit -.EE +This shell command can be defined to be executed after the screen is +redrawn or if the terminal is resized. +.SS on\-quit .PP This shell command can be defined to be executed before quit. .SH PREFIXES +.PP The following command prefixes are used by lf: +.IP +.nf +\f[C] +: read (default) builtin/custom command +$ shell shell command +% shell\-pipe shell command running with the ui +! shell\-wait shell command waiting for key press +& shell\-async shell command running asynchronously +\f[R] +.fi .PP -.EX - : read (default) builtin/custom command - $ shell shell command - % shell-pipe shell command running with the ui - ! shell-wait shell command waiting for key press - & shell-async shell command running asynchronously -.EE -.PP -The same evaluator is used for the command line and the configuration file for read and shell commands. The difference is that prefixes are not necessary in the command line. Instead, different modes are provided to read corresponding commands. These modes are mapped to the prefix keys above by default. +The same evaluator is used for the command line and the configuration +file for read and shell commands. +The difference is that prefixes are not necessary in the command line. +Instead, different modes are provided to read corresponding commands. +These modes are mapped to the prefix keys above by default. .SH SYNTAX -Characters from '#' to newline are comments and ignored: .PP -.EX - # comments start with '#' -.EE +Characters from \f[C]#\f[R] to newline are comments and ignored: +.IP +.nf +\f[C] +# comments start with \[ga]#\[ga] +\f[R] +.fi .PP -There are five special commands ('set', 'setlocal', 'map', 'cmap', and 'cmd') for configuration. +There are five special commands (\f[C]set\f[R], \f[C]setlocal\f[R], +\f[C]map\f[R], \f[C]cmap\f[R], and \f[C]cmd\f[R]) for configuration. .PP -Command 'set' is used to set an option which can be boolean, integer, or string: +Command \f[C]set\f[R] is used to set an option which can be boolean, +integer, or string: +.IP +.nf +\f[C] +set hidden # boolean enable +set hidden true # boolean enable +set nohidden # boolean disable +set hidden false # boolean disable +set hidden! # boolean toggle +set scrolloff 10 # integer value +set sortby time # string value w/o quotes +set sortby \[aq]time\[aq] # string value with single quotes (whitespaces) +set sortby \[dq]time\[dq] # string value with double quotes (backslash escapes) +\f[R] +.fi .PP -.EX - set hidden # boolean enable - set hidden true # boolean enable - set nohidden # boolean disable - set hidden false # boolean disable - set hidden! # boolean toggle - set scrolloff 10 # integer value - set sortby time # string value w/o quotes - set sortby 'time' # string value with single quotes (whitespaces) - set sortby "time" # string value with double quotes (backslash escapes) -.EE +Command \f[C]setlocal\f[R] is used to set a local option for a directory +which can be boolean or string. +Currently supported local options are \f[C]dirfirst\f[R], +\f[C]dironly\f[R], \f[C]hidden\f[R], \f[C]info\f[R], \f[C]reverse\f[R], +and \f[C]sortby\f[R]. +Adding a trailing path separator (i.e. +\f[C]/\f[R] for Unix and \f[C]\[rs]\f[R] for Windows) sets the option +for the given directory along with its subdirectories: +.IP +.nf +\f[C] +setlocal /foo/bar hidden # boolean enable +setlocal /foo/bar hidden true # boolean enable +setlocal /foo/bar nohidden # boolean disable +setlocal /foo/bar hidden false # boolean disable +setlocal /foo/bar hidden! # boolean toggle +setlocal /foo/bar sortby time # string value w/o quotes +setlocal /foo/bar sortby \[aq]time\[aq] # string value with single quotes (whitespaces) +setlocal /foo/bar sortby \[dq]time\[dq] # string value with double quotes (backslash escapes) +setlocal /foo/bar hidden # for only \[aq]/foo/bar\[aq] directory +setlocal /foo/bar/ hidden # for \[aq]/foo/bar\[aq] and its subdirectories (e.g. \[aq]/foo/bar/baz\[aq]) +\f[R] +.fi .PP -Command 'setlocal' is used to set a local option for a directory which can be boolean or string. Currently supported local options are 'dirfirst', 'dironly', 'hidden', 'info', 'reverse', and 'sortby'. Adding a trailing path separator (i.e. '/' for Unix and '\e' for Windows) sets the option for the given directory along with its subdirectories: +Command \[aq]map\[aq] is used to bind a key to a command which can be +builtin command, custom command, or shell command: +.IP +.nf +\f[C] +map gh cd \[ti] # builtin command +map D trash # custom command +map i $less $f # shell command +map U !du \-csh * # waiting shell command +\f[R] +.fi .PP -.EX - setlocal /foo/bar hidden # boolean enable - setlocal /foo/bar hidden true # boolean enable - setlocal /foo/bar nohidden # boolean disable - setlocal /foo/bar hidden false # boolean disable - setlocal /foo/bar hidden! # boolean toggle - setlocal /foo/bar sortby time # string value w/o quotes - setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) - setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) - setlocal /foo/bar hidden # for only '/foo/bar' directory - setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') -.EE -.PP -Command 'map' is used to bind a key to a command which can be builtin command, custom command, or shell command: -.PP -.EX - map gh cd ~ # builtin command - map D trash # custom command - map i $less $f # shell command - map U !du -csh * # waiting shell command -.EE -.PP -Command 'cmap' is used to bind a key on the command line to a command line command or any other command: -.PP -.EX - cmap cmd-escape - cmap set incsearch! -.EE +Command \[aq]cmap\[aq] is used to bind a key on the command line to a +command line command or any other command: +.IP +.nf +\f[C] +cmap cmd\-escape +cmap set incsearch! +\f[R] +.fi .PP You can delete an existing binding by leaving the expression empty: +.IP +.nf +\f[C] +map gh # deletes \[aq]gh\[aq] mapping +cmap # deletes \[aq]\[aq] mapping +\f[R] +.fi .PP -.EX - map gh # deletes 'gh' mapping - cmap # deletes '' mapping -.EE -.PP -Command 'cmd' is used to define a custom command: -.PP -.EX - cmd usage $du -h -d1 | less -.EE +Command \f[C]cmd\f[R] is used to define a custom command: +.IP +.nf +\f[C] +cmd usage $du \-h \-d1 | less +\f[R] +.fi .PP You can delete an existing command by leaving the expression empty: +.IP +.nf +\f[C] +cmd trash # deletes \[aq]trash\[aq] command +\f[R] +.fi .PP -.EX - cmd trash # deletes 'trash' command -.EE +If there is no prefix then \f[C]:\f[R] is assumed: +.IP +.nf +\f[C] +map zt set info time +\f[R] +.fi .PP -If there is no prefix then ':' is assumed: +An explicit \f[C]:\f[R] can be provided to group statements until a +newline which is especially useful for \f[C]map\f[R] and \f[C]cmd\f[R] +commands: +.IP +.nf +\f[C] +map st :set sortby time; set info time +\f[R] +.fi .PP -.EX - map zt set info time -.EE -.PP -An explicit ':' can be provided to group statements until a newline which is especially useful for 'map' and 'cmd' commands: -.PP -.EX - map st :set sortby time; set info time -.EE -.PP -If you need multiline you can wrap statements in '{{' and '}}' after the proper prefix. -.PP -.EX - map st :{{ - set sortby time - set info time - }} -.EE +If you need multiline you can wrap statements in \f[C]{{\f[R] and +\f[C]}}\f[R] after the proper prefix. +.IP +.nf +\f[C] +map st :{{ + set sortby time + set info time +}} +\f[R] +.fi .SH KEY MAPPINGS -Regular keys are assigned to a command with the usual syntax: .PP -.EX - map a down -.EE +Regular keys are assigned to a command with the usual syntax: +.IP +.nf +\f[C] +map a down +\f[R] +.fi .PP Keys combined with the shift key simply use the uppercase letter: +.IP +.nf +\f[C] +map A down +\f[R] +.fi .PP -.EX - map A down -.EE -.PP -Special keys are written in between '<' and '>' characters and always use lowercase letters: -.PP -.EX - map down -.EE +Special keys are written in between \f[C]<\f[R] and \f[C]>\f[R] +characters and always use lowercase letters: +.IP +.nf +\f[C] +map down +\f[R] +.fi .PP Angle brackets can be assigned with their special names: +.IP +.nf +\f[C] +map down +map down +\f[R] +.fi .PP -.EX - map down - map down -.EE +Function keys are prefixed with \f[C]f\f[R] character: +.IP +.nf +\f[C] +map down +\f[R] +.fi .PP -Function keys are prefixed with 'f' character: +Keys combined with the control key are prefixed with \f[C]c\f[R] +character: +.IP +.nf +\f[C] +map down +\f[R] +.fi .PP -.EX - map down -.EE +Keys combined with the alt key are assigned in two different ways +depending on the behavior of your terminal. +Older terminals (e.g. +xterm) may set the 8th bit of a character when the alt key is pressed. +On these terminals, you can use the corresponding byte for the mapping: +.IP +.nf +\f[C] +map \['a] down +\f[R] +.fi .PP -Keys combined with the control key are prefixed with 'c' character: -.PP -.EX - map down -.EE -.PP -Keys combined with the alt key are assigned in two different ways depending on the behavior of your terminal. Older terminals (e.g. xterm) may set the 8th bit of a character when the alt key is pressed. On these terminals, you can use the corresponding byte for the mapping: -.PP -.EX - map รก down -.EE -.PP -Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed. lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms). On these terminals, keys combined with the alt key are prefixed with 'a' character: -.PP -.EX - map down -.EE +Newer terminals (e.g. +gnome\-terminal) may prefix the key with an escape key when the alt key +is pressed. +lf uses the escape delaying mechanism to recognize alt keys in these +terminals (delay is 100ms). +On these terminals, keys combined with the alt key are prefixed with +\f[C]a\f[R] character: +.IP +.nf +\f[C] +map down +\f[R] +.fi .PP It is possible to combine special keys with modifiers: +.IP +.nf +\f[C] +map down +\f[R] +.fi .PP -.EX - map down -.EE +WARNING: Some key combinations will likely be intercepted by your OS, +window manager, or terminal. +Other key combinations cannot be recognized by lf due to the way +terminals work (e.g. +\f[C]Ctrl+h\f[R] combination sends a backspace key instead). +The easiest way to find out the name of a key combination and whether it +will work on your system is to press the key while lf is running and +read the name from the \f[C]unknown mapping\f[R] error. .PP -WARNING: Some key combinations will likely be intercepted by your OS, window manager, or terminal. Other key combinations cannot be recognized by lf due to the way terminals work (e.g. `Ctrl+h` combination sends a backspace key instead). The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the "unknown mapping" error. +Mouse buttons are prefixed with \f[C]m\f[R] character: +.IP +.nf +\f[C] +map down # primary +map down # secondary +map down # middle +map down +map down +map down +map down +map down +\f[R] +.fi .PP -Mouse buttons are prefixed with 'm' character: -.PP -.EX - map down # primary - map down # secondary - map down # middle - map down - map down - map down - map down - map down -.EE -.PP -Mouse wheel events are also prefixed with 'm' character: -.PP -.EX - map down - map down - map down - map down -.EE +Mouse wheel events are also prefixed with \f[C]m\f[R] character: +.IP +.nf +\f[C] +map down +map down +map down +map down +\f[R] +.fi .SH PUSH MAPPINGS -The usual way to map a key sequence is to assign it to a named or unnamed command. While this provides a clean way to remap builtin keys as well as other commands, it can be limiting at times. For this reason 'push' command is provided by lf. This command is used to simulate key pushes given as its arguments. You can 'map' a key to a 'push' command with an argument to create various keybindings. .PP -This is mainly useful for two purposes. First, it can be used to map a command with a command count: +The usual way to map a key sequence is to assign it to a named or +unnamed command. +While this provides a clean way to remap builtin keys as well as other +commands, it can be limiting at times. +For this reason \f[C]push\f[R] command is provided by lf. +This command is used to simulate key pushes given as its arguments. +You can \f[C]map\f[R] a key to a \f[C]push\f[R] command with an argument +to create various keybindings. .PP -.EX - map push 10j -.EE +This is mainly useful for two purposes. +First, it can be used to map a command with a command count: +.IP +.nf +\f[C] +map push 10j +\f[R] +.fi .PP -Second, it can be used to avoid typing the name when a command takes arguments: +Second, it can be used to avoid typing the name when a command takes +arguments: +.IP +.nf +\f[C] +map r push :rename +\f[R] +.fi .PP -.EX - map r push :rename -.EE -.PP -One thing to be careful is that since 'push' command works with keys instead of commands it is possible to accidentally create recursive bindings: -.PP -.EX - map j push 2j -.EE +One thing to be careful is that since \f[C]push\f[R] command works with +keys instead of commands it is possible to accidentally create recursive +bindings: +.IP +.nf +\f[C] +map j push 2j +\f[R] +.fi .PP These types of bindings create a deadlock when executed. .SH SHELL COMMANDS -Regular shell commands are the most basic command type that is useful for many purposes. For example, we can write a shell command to move selected file(s) to trash. A first attempt to write such a command may look like this: .PP -.EX - cmd trash ${{ - mkdir -p ~/.trash - if [ -z "$fs" ]; then - mv "$f" ~/.trash - else - IFS="$(printf '\en\et')"; mv $fs ~/.trash - fi - }} -.EE +Regular shell commands are the most basic command type that is useful +for many purposes. +For example, we can write a shell command to move selected file(s) to +trash. +A first attempt to write such a command may look like this: +.IP +.nf +\f[C] +cmd trash ${{ + mkdir \-p \[ti]/.trash + if [ \-z \[dq]$fs\[dq] ]; then + mv \[dq]$f\[dq] \[ti]/.trash + else + IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fs \[ti]/.trash + fi +}} +\f[R] +.fi .PP -We check '$fs' to see if there are any selected files. Otherwise we just delete the current file. Since this is such a common pattern, a separate '$fx' variable is provided. We can use this variable to get rid of the conditional: +We check \f[C]$fs\f[R] to see if there are any selected files. +Otherwise we just delete the current file. +Since this is such a common pattern, a separate \f[C]$fx\f[R] variable +is provided. +We can use this variable to get rid of the conditional: +.IP +.nf +\f[C] +cmd trash ${{ + mkdir \-p \[ti]/.trash + IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash +}} +\f[R] +.fi .PP -.EX - cmd trash ${{ - mkdir -p ~/.trash - IFS="$(printf '\en\et')"; mv $fx ~/.trash - }} -.EE +The trash directory is checked each time the command is executed. +We can move it outside of the command so it would only run once at +startup: +.IP +.nf +\f[C] +${{ mkdir \-p \[ti]/.trash }} + +cmd trash ${{ IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash }} +\f[R] +.fi .PP -The trash directory is checked each time the command is executed. We can move it outside of the command so it would only run once at startup: +Since these are one liners, we can drop \f[C]{{\f[R] and \f[C]}}\f[R]: +.IP +.nf +\f[C] +$mkdir \-p \[ti]/.trash + +cmd trash $IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash +\f[R] +.fi .PP -.EX - ${{ mkdir -p ~/.trash }} -.EE -.PP -.EX - cmd trash ${{ IFS="$(printf '\en\et')"; mv $fx ~/.trash }} -.EE -.PP -Since these are one liners, we can drop '{{' and '}}': -.PP -.EX - $mkdir -p ~/.trash -.EE -.PP -.EX - cmd trash $IFS="$(printf '\en\et')"; mv $fx ~/.trash -.EE -.PP -Finally note that we set 'IFS' variable manually in these commands. Instead we could use the 'ifs' option to set it for all shell commands (i.e. 'set ifs "\en"'). This can be especially useful for interactive use (e.g. '$rm $f' or '$rm $fs' would simply work). This option is not set by default as it can behave unexpectedly for new users. However, use of this option is highly recommended and it is assumed in the rest of the documentation. +Finally note that we set \f[C]IFS\f[R] variable manually in these +commands. +Instead we could use the \f[C]ifs\f[R] option to set it for all shell +commands (i.e. +\f[C]set ifs \[dq]\[rs]n\[dq]\f[R]). +This can be especially useful for interactive use (e.g. +\f[C]$rm $f\f[R] or \f[C]$rm $fs\f[R] would simply work). +This option is not set by default as it can behave unexpectedly for new +users. +However, use of this option is highly recommended and it is assumed in +the rest of the documentation. .SH PIPING SHELL COMMANDS -Regular shell commands have some limitations in some cases. When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. Also, even when there is no output or error, the ui still needs to be paused while the command is running. This can cause flickering on the screen for short commands and similar distractions for longer commands. .PP -Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui. This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases. +Regular shell commands have some limitations in some cases. +When an output or error message is given and the command exits +afterwards, the ui is immediately resumed and there is no way to see the +message without dropping to shell again. +Also, even when there is no output or error, the ui still needs to be +paused while the command is running. +This can cause flickering on the screen for short commands and similar +distractions for longer commands. .PP -For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name: +Instead of pausing the ui, piping shell commands connects stdin, stdout, +and stderr of the command to the statline in the bottom of the ui. +This can be useful for programs following the Unix philosophy to give no +output in the success case, and brief error messages or prompts in other +cases. .PP -.EX - cmd rename %mv -i $f $1 -.EE +For example, following rename command prompts for overwrite in the +statline if there is an existing file with the given name: +.IP +.nf +\f[C] +cmd rename %mv \-i $f $1 +\f[R] +.fi .PP -You can also output error messages in the command and it will show up in the statline. For example, an alternative rename command may look like this: -.PP -.EX - cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 -.EE +You can also output error messages in the command and it will show up in +the statline. +For example, an alternative rename command may look like this: +.IP +.nf +\f[C] +cmd rename %[ \-e $1 ] && printf \[dq]file exists\[dq] || mv $f $1 +\f[R] +.fi .PP Note that input is line buffered and output and error are byte buffered. .SH WAITING SHELL COMMANDS -Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. These can be useful to see the output of a program before the ui is resumed. Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline. +.PP +Waiting shell commands are similar to regular shell commands except that +they wait for a key press when the command is finished. +These can be useful to see the output of a program before the ui is +resumed. +Waiting shell commands are more appropriate than piping shell commands +when the command is verbose and the output is best displayed as +multiline. .SH ASYNCHRONOUS SHELL COMMANDS -Asynchronous shell commands are used to start a command in the background and then resume operation without waiting for the command to finish. Stdin, stdout, and stderr of the command is neither connected to the terminal nor to the ui. +.PP +Asynchronous shell commands are used to start a command in the +background and then resume operation without waiting for the command to +finish. +Stdin, stdout, and stderr of the command is neither connected to the +terminal nor to the ui. .SH REMOTE COMMANDS -One of the more advanced features in lf is remote commands. All clients connect to a server on startup. It is possible to send commands to all or any of the connected clients over the common server. This is used internally to notify file selection changes to other clients. .PP -To use this feature, you need to use a client which supports communicating with a Unix domain socket. OpenBSD implementation of netcat (nc) is one such example. You can use it to send a command to the socket file: +One of the more advanced features in lf is remote commands. +All clients connect to a server on startup. +It is possible to send commands to all or any of the connected clients +over the common server. +This is used internally to notify file selection changes to other +clients. .PP -.EX - echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock -.EE +To use this feature, you need to use a client which supports +communicating with a Unix domain socket. +OpenBSD implementation of netcat (nc) is one such example. +You can use it to send a command to the socket file: +.IP +.nf +\f[C] +echo \[aq]send echo hello world\[aq] | nc \-U ${XDG_RUNTIME_DIR:\-/tmp}/lf.${USER}.sock +\f[R] +.fi .PP -Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. When using lf, you do not need to specify the address of the socket file. This is the recommended way of using remote commands since it is shorter and immune to socket file address changes: +Since such a client may not be available everywhere, lf comes bundled +with a command line flag to be used as such. +When using lf, you do not need to specify the address of the socket +file. +This is the recommended way of using remote commands since it is shorter +and immune to socket file address changes: +.IP +.nf +\f[C] +lf \-remote \[aq]send echo hello world\[aq] +\f[R] +.fi .PP -.EX - lf -remote 'send echo hello world' -.EE +In this command \f[C]send\f[R] is used to send the rest of the string as +a command to all connected clients. +You can optionally give it an id number to send a command to a single +client: +.IP +.nf +\f[C] +lf \-remote \[aq]send 1234 echo hello world\[aq] +\f[R] +.fi .PP -In this command 'send' is used to send the rest of the string as a command to all connected clients. You can optionally give it an id number to send a command to a single client: +All clients have a unique id number but you may not be aware of the id +number when you are writing a command. +For this purpose, an \f[C]$id\f[R] variable is exported to the +environment for shell commands. +The value of this variable is set to the process id of the client. +You can use it to send a remote command from a client to the server +which in return sends a command back to itself. +So now you can display a message in the current client by calling the +following in a shell command: +.IP +.nf +\f[C] +lf \-remote \[dq]send $id echo hello world\[dq] +\f[R] +.fi .PP -.EX - lf -remote 'send 1234 echo hello world' -.EE +Since lf does not have control flow syntax, remote commands are used for +such needs. +For example, you can configure the number of columns in the ui with +respect to the terminal width as follows: +.IP +.nf +\f[C] +cmd recol %{{ + if [ $lf_width \-le 80 ]; then + lf \-remote \[dq]send $id set ratios 1:2\[dq] + elif [ $lf_width \-le 160 ]; then + lf \-remote \[dq]send $id set ratios 1:2:3\[dq] + else + lf \-remote \[dq]send $id set ratios 1:2:3:5\[dq] + fi +}} +\f[R] +.fi .PP -All clients have a unique id number but you may not be aware of the id number when you are writing a command. For this purpose, an '$id' variable is exported to the environment for shell commands. The value of this variable is set to the process id of the client. You can use it to send a remote command from a client to the server which in return sends a command back to itself. So now you can display a message in the current client by calling the following in a shell command: -.PP -.EX - lf -remote "send $id echo hello world" -.EE -.PP -Since lf does not have control flow syntax, remote commands are used for such needs. For example, you can configure the number of columns in the ui with respect to the terminal width as follows: -.PP -.EX - cmd recol %{{ - if [ $lf_width -le 80 ]; then - lf -remote "send $id set ratios 1:2" - elif [ $lf_width -le 160 ]; then - lf -remote "send $id set ratios 1:2:3" - else - lf -remote "send $id set ratios 1:2:3:5" - fi - }} -.EE -.PP -In addition, the 'query' command can be used to obtain information about a specific lf instance by providing its id: -.PP -.EX - lf -remote "query $id maps" -.EE +In addition, the \f[C]query\f[R] command can be used to obtain +information about a specific lf instance by providing its id: +.IP +.nf +\f[C] +lf \-remote \[dq]query $id maps\[dq] +\f[R] +.fi .PP The following types of information are supported: +.IP +.nf +\f[C] +maps list of mappings created by the \[aq]map\[aq] command +cmaps list of mappings created by the \[aq]cmap\[aq] command +cmds list of commands created by the \[aq]cmd\[aq] command +jumps contents of the jump list, showing previously visited locations +history list of previously executed commands on the command line +\f[R] +.fi .PP -.EX - maps list of mappings created by the 'map' command - cmaps list of mappings created by the 'cmap' command - cmds list of commands created by the 'cmd' command - jumps contents of the jump list, showing previously visited locations - history list of previously executed commands on the command line -.EE +This is useful for scripting actions based on the internal state of lf. +For example, to select a previous command using fzf and execute it: +.IP +.nf +\f[C] +map ${{ + clear + cmd=$( + lf \-remote \[dq]query $id history\[dq] | + awk \-F\[aq]\[rs]t\[aq] \[aq]NR > 1 { print $NF}\[aq] | + sort \-u | + fzf \-\-reverse \-\-prompt=\[aq]Execute command: \[aq] + ) + lf \-remote \[dq]send $id $cmd\[dq] +}} +\f[R] +.fi .PP -This is useful for scripting actions based on the internal state of lf. For example, to select a previous command using fzf and execute it: +There is also a \f[C]quit\f[R] command to quit the server when there are +no connected clients left, and a \f[C]quit!\f[R] command to force quit +the server by closing client connections first: +.IP +.nf +\f[C] +lf \-remote \[aq]quit\[aq] +lf \-remote \[aq]quit!\[aq] +\f[R] +.fi .PP -.EX - map ${{ - clear - cmd=$( - lf -remote "query $id history" | - awk -F'\et' 'NR > 1 { print $NF}' | - sort -u | - fzf --reverse --prompt='Execute command: ' - ) - lf -remote "send $id $cmd" - }} -.EE -.PP -There is also a 'quit' command to quit the server when there are no connected clients left, and a 'quit!' command to force quit the server by closing client connections first: -.PP -.EX - lf -remote 'quit' - lf -remote 'quit!' -.EE -.PP -Lastly, there is a 'conn' command to connect the server as a client. This should not be needed for users. +Lastly, there is a \f[C]conn\f[R] command to connect the server as a +client. +This should not be needed for users. .SH FILE OPERATIONS -lf uses its own builtin copy and move operations by default. These are implemented as asynchronous operations and progress is shown in the bottom ruler. These commands do not overwrite existing files or directories with the same name. Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories. Only file modes and (some) timestamps can be preserved (see `preserve` option), all other attributes are ignored including ownership, context, and xattr. Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed. Moving is performed using the rename operation of the underlying OS. For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors. Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation. .PP -File operations can be performed on the current selected file or alternatively on multiple files by selecting them first. When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to a file. The actual file copying takes place when you 'paste'. Similarly 'paste' after a 'cut' operation moves the file. +lf uses its own builtin copy and move operations by default. +These are implemented as asynchronous operations and progress is shown +in the bottom ruler. +These commands do not overwrite existing files or directories with the +same name. +Instead, a suffix that is compatible with \f[C]\-\-backup=numbered\f[R] +option in GNU cp is added to the new files or directories. +Only file modes and (some) timestamps can be preserved (see +\f[C]preserve\f[R] option), all other attributes are ignored including +ownership, context, and xattr. +Special files such as character and block devices, named pipes, and +sockets are skipped and links are not followed. +Moving is performed using the rename operation of the underlying OS. +For cross\-device moving, lf falls back to copying and then deletes the +original files if there are no errors. +Operation errors are shown in the message line as well as the log file +and they do not preemptively finish the corresponding file operation. .PP -You can customize copy and move operations by defining a 'paste' command. This is a special command that is called when it is defined instead of the builtin implementation. You can use the following example as a starting point: +File operations can be performed on the current selected file or +alternatively on multiple files by selecting them first. +When you \f[C]copy\f[R] a file, lf doesn\[aq]t actually copy the file on +the disk, but only records its name to a file. +The actual file copying takes place when you \f[C]paste\f[R]. +Similarly \f[C]paste\f[R] after a \f[C]cut\f[R] operation moves the +file. .PP -.EX - cmd paste %{{ - load=$(cat ~/.local/share/lf/files) - mode=$(echo "$load" | sed -n '1p') - list=$(echo "$load" | sed '1d') - if [ $mode = 'copy' ]; then - cp -R $list . - elif [ $mode = 'move' ]; then - mv $list . - rm ~/.local/share/lf/files - lf -remote 'send clear' - fi - }} -.EE +You can customize copy and move operations by defining a \f[C]paste\f[R] +command. +This is a special command that is called when it is defined instead of +the builtin implementation. +You can use the following example as a starting point: +.IP +.nf +\f[C] +cmd paste %{{ + load=$(cat \[ti]/.local/share/lf/files) + mode=$(echo \[dq]$load\[dq] | sed \-n \[aq]1p\[aq]) + list=$(echo \[dq]$load\[dq] | sed \[aq]1d\[aq]) + if [ $mode = \[aq]copy\[aq] ]; then + cp \-R $list . + elif [ $mode = \[aq]move\[aq] ]; then + mv $list . + rm \[ti]/.local/share/lf/files + lf \-remote \[aq]send clear\[aq] + fi +}} +\f[R] +.fi .PP -Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls. +Some useful things to be considered are to use the backup +(\f[C]\-\-backup\f[R]) and/or preserve attributes (\f[C]\-a\f[R]) +options with \f[C]cp\f[R] and \f[C]mv\f[R] commands if they support it +(i.e. +GNU implementation), change the command type to asynchronous, or use +\f[C]rsync\f[R] command with progress bar option for copying and feed +the progress to the client periodically with remote \f[C]echo\f[R] +calls. .PP -By default, lf does not assign 'delete' command to a key to protect new users. You can customize file deletion by defining a 'delete' command. You can also assign a key to this command if you like. An example command to move selected files to a trash folder and remove files completely after a prompt are provided in the example configuration file. +By default, lf does not assign \f[C]delete\f[R] command to a key to +protect new users. +You can customize file deletion by defining a \f[C]delete\f[R] command. +You can also assign a key to this command if you like. +An example command to move selected files to a trash folder and remove +files completely after a prompt are provided in the example +configuration file. .SH SEARCHING FILES -There are two mechanisms implemented in lf to search a file in the current directory. Searching is the traditional method to move the selection to a file matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes. .PP -Searching mechanism is implemented with commands 'search' (default '/'), 'search-back' (default '?'), 'search-next' (default 'n'), and 'search-prev' (default 'N'). You can enable 'globsearch' option to match with a glob pattern. Globbing supports '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. You can enable 'incsearch' option to jump to the current match at each keystroke while typing. In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-escape' to cancel the search. You can also map some other commands with 'cmap' to accept the search and execute the command immediately afterwards. For example, you can use the right arrow key to finish the search and open the selected file with the following mapping: +There are two mechanisms implemented in lf to search a file in the +current directory. +Searching is the traditional method to move the selection to a file +matching a given pattern. +Finding is an alternative way to search for a pattern possibly using +fewer keystrokes. .PP -.EX - cmap :cmd-enter; open -.EE +Searching mechanism is implemented with commands \f[C]search\f[R] +(default \f[C]/\f[R]), \f[C]search\-back\f[R] (default \f[C]?\f[R]), +\f[C]search\-next\f[R] (default \f[C]n\f[R]), and \f[C]search\-prev\f[R] +(default \f[C]N\f[R]). +You can enable \f[C]globsearch\f[R] option to match with a glob pattern. +Globbing supports \f[C]*\f[R] to match any sequence, \f[C]?\f[R] to +match any character, and \f[C][...]\f[R] or \f[C][\[ha]...]\f[R] to +match character sets or ranges. +You can enable \f[C]incsearch\f[R] option to jump to the current match +at each keystroke while typing. +In this mode, you can either use \f[C]cmd\-enter\f[R] to accept the +search or use \f[C]cmd\-escape\f[R] to cancel the search. +You can also map some other commands with \f[C]cmap\f[R] to accept the +search and execute the command immediately afterwards. +For example, you can use the right arrow key to finish the search and +open the selected file with the following mapping: +.IP +.nf +\f[C] +cmap :cmd\-enter; open +\f[R] +.fi .PP -Finding mechanism is implemented with commands 'find' (default 'f'), 'find-back' (default 'F'), 'find-next' (default ';'), 'find-prev' (default ','). You can disable 'anchorfind' option to match a pattern at an arbitrary position in the filename instead of the beginning. You can set the number of keys to match using 'findlen' option. If you set this value to zero, then the the keys are read until there is only a single match. Default values of these two options are set to jump to the first file with the given initial. +Finding mechanism is implemented with commands \f[C]find\f[R] (default +\f[C]f\f[R]), \f[C]find\-back\f[R] (default \f[C]F\f[R]), +\f[C]find\-next\f[R] (default \f[C];\f[R]), \f[C]find\-prev\f[R] +(default \f[C],\f[R]). +You can disable \f[C]anchorfind\f[R] option to match a pattern at an +arbitrary position in the filename instead of the beginning. +You can set the number of keys to match using \f[C]findlen\f[R] option. +If you set this value to zero, then the the keys are read until there is +only a single match. +Default values of these two options are set to jump to the first file +with the given initial. .PP -Some options effect both searching and finding. You can disable 'wrapscan' option to prevent searches to wrap around at the end of the file list. You can disable 'ignorecase' option to match cases in the pattern and the filename. This option is already automatically overridden if the pattern contains upper case characters. You can disable 'smartcase' option to disable this behavior. Two similar options 'ignoredia' and 'smartdia' are provided to control matching diacritics in latin letters. +Some options effect both searching and finding. +You can disable \f[C]wrapscan\f[R] option to prevent searches to wrap +around at the end of the file list. +You can disable \f[C]ignorecase\f[R] option to match cases in the +pattern and the filename. +This option is already automatically overridden if the pattern contains +upper case characters. +You can disable \f[C]smartcase\f[R] option to disable this behavior. +Two similar options \f[C]ignoredia\f[R] and \f[C]smartdia\f[R] are +provided to control matching diacritics in latin letters. .SH OPENING FILES -You can define a an 'open' command (default 'l' and '') to configure file opening. This command is only called when the current file is not a directory, otherwise the directory is entered instead. You can define it just as you would define any other command: .PP -.EX - cmd open $vi $fx -.EE +You can define a an \f[C]open\f[R] command (default \f[C]l\f[R] and +\f[C]\f[R]) to configure file opening. +This command is only called when the current file is not a directory, +otherwise the directory is entered instead. +You can define it just as you would define any other command: +.IP +.nf +\f[C] +cmd open $vi $fx +\f[R] +.fi .PP It is possible to use different command types: +.IP +.nf +\f[C] +cmd open &xdg\-open $f +\f[R] +.fi .PP -.EX - cmd open &xdg-open $f -.EE +You may want to use either file extensions or mime types from +\f[C]file\f[R] command: +.IP +.nf +\f[C] +cmd open ${{ + case $(file \-\-mime\-type \-Lb $f) in + text/*) vi $fx;; + *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;; + esac +}} +\f[R] +.fi .PP -You may want to use either file extensions or mime types from 'file' command: +You may want to use \f[C]setsid\f[R] before your opener command to have +persistent processes that continue to run after lf quits. .PP -.EX - cmd open ${{ - case $(file --mime-type -Lb $f) in - text/*) vi $fx;; - *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; - esac - }} -.EE +Regular shell commands (i.e. +\f[C]$\f[R]) drop to terminal which results in a flicker for commands +that finishes immediately (e.g. +\f[C]xdg\-open\f[R] in the above example). +If you want to use asynchronous shell commands (i.e. +\f[C]&\f[R]) but also want to use the terminal when necessary (e.g. +\f[C]vi\f[R] in the above exxample), you can use a remote command: +.IP +.nf +\f[C] +cmd open &{{ + case $(file \-\-mime\-type \-Lb $f) in + text/*) lf \-remote \[dq]send $id \[rs]$vi \[rs]$fx\[dq];; + *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;; + esac +}} +\f[R] +.fi .PP -You may want to use 'setsid' before your opener command to have persistent processes that continue to run after lf quits. -.PP -Regular shell commands (i.e. '$') drop to terminal which results in a flicker for commands that finishes immediately (e.g. 'xdg-open' in the above example). If you want to use asynchronous shell commands (i.e. '&') but also want to use the terminal when necessary (e.g. 'vi' in the above exxample), you can use a remote command: -.PP -.EX - cmd open &{{ - case $(file --mime-type -Lb $f) in - text/*) lf -remote "send $id \e$vi \e$fx";; - *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; - esac - }} -.EE -.PP -Note, asynchronous shell commands run in their own process group by default so they do not require the manual use of 'setsid'. +Note, asynchronous shell commands run in their own process group by +default so they do not require the manual use of \f[C]setsid\f[R]. .PP Following command is provided by default: +.IP +.nf +\f[C] +cmd open &$OPENER $f +\f[R] +.fi .PP -.EX - cmd open &$OPENER $f -.EE -.PP -You may also use any other existing file openers as you like. Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or 'mimeo' to name a few. +You may also use any other existing file openers as you like. +Possible options are \f[C]libfile\-mimeinfo\-perl\f[R] (executable name +is \f[C]mimeopen\f[R]), \f[C]rifle\f[R] (ranger\[aq]s default file +opener), or \f[C]mimeo\f[R] to name a few. .SH PREVIEWING FILES -lf previews files on the preview pane by printing the file until the end or the preview pane is filled. This output can be enhanced by providing a custom preview script for filtering. This can be used to highlight source codes, list contents of archive files or view pdf or image files to name a few. For coloring lf recognizes ansi escape codes. .PP -In order 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 file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. 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: +lf previews files on the preview pane by printing the file until the end +or the preview pane is filled. +This output can be enhanced by providing a custom preview script for +filtering. +This can be used to highlight source codes, list contents of archive +files or view pdf or image files to name a few. +For coloring lf recognizes ansi escape codes. .PP -.EX - set previewer ~/.config/lf/pv.sh - map i $~/.config/lf/pv.sh $f | less -R -.EE +In order to use this feature you need to set the value of +\f[C]previewer\f[R] option to the path of an executable file. +Five arguments are passed to the file, (1) current file name, (2) width, +(3) height, (4) horizontal position, and (5) vertical position of +preview pane respectively. +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: +.IP +.nf +\f[C] +set previewer \[ti]/.config/lf/pv.sh +map i $\[ti]/.config/lf/pv.sh $f | less \-R +\f[R] +.fi .PP -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: +For \f[C]less\f[R] pager, you may instead utilize \f[C]LESSOPEN\f[R] +mechanism so that useful information about the file such as the full +path of the file can still be displayed in the statusline below: +.IP +.nf +\f[C] +set previewer \[ti]/.config/lf/pv.sh +map i $LESSOPEN=\[aq]| \[ti]/.config/lf/pv.sh %s\[aq] less \-R $f +\f[R] +.fi .PP -.EX - set previewer ~/.config/lf/pv.sh - map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f -.EE +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 \f[C]file\f[R] +command. +Extensions can then be used to match cleanly within a conditional: +.IP +.nf +\f[C] +#!/bin/sh + +case \[dq]$1\[dq] in + *.tar*) tar tf \[dq]$1\[dq];; + *.zip) unzip \-l \[dq]$1\[dq];; + *.rar) unrar l \[dq]$1\[dq];; + *.7z) 7z l \[dq]$1\[dq];; + *.pdf) pdftotext \[dq]$1\[dq] \-;; + *) highlight \-O ansi \[dq]$1\[dq];; +esac +\f[R] +.fi .PP -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: +Another important consideration for efficiency is the use of programs +with short startup times for preview. +For this reason, \f[C]highlight\f[R] is recommended over +\f[C]pygmentize\f[R] for syntax highlighting. +Besides, it is also important that the application is processing the +file on the fly rather than first reading it to the memory and then do +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 \f[C]|| true\f[R] command to avoid such errors: +.IP +.nf +\f[C] +highlight \-O ansi \[dq]$1\[dq] || true +\f[R] +.fi .PP -.EX - #!/bin/sh -.EE -.PP -.EX - case "$1" in - *.tar*) tar tf "$1";; - *.zip) unzip -l "$1";; - *.rar) unrar l "$1";; - *.7z) 7z l "$1";; - *.pdf) pdftotext "$1" -;; - *) highlight -O ansi "$1";; - esac -.EE -.PP -Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do 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: -.PP -.EX - highlight -O ansi "$1" || true -.EE -.PP -You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have a mechanism to add user customizations as well. See the related documentations for more information. +You may also use an existing preview filter as you like. +Your system may already come with a preview filter named +\f[C]lesspipe\f[R]. +These filters may have a mechanism to add user customizations as well. +See the related documentations for more information. .SH CHANGING DIRECTORY -lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository at https://github.com/gokcehan/lf/tree/master/etc .PP -There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed. You can define it just as you would define any other command: +lf changes the working directory of the process to the current directory +so that shell commands always work in the displayed directory. +After quitting, it returns to the original directory where it is first +launched like all shell programs. +If you want to stay in the current directory after quitting, you can use +one of the example lfcd wrapper shell scripts provided in the repository +at +https://github.com/gokcehan/lf/tree/master/etc (https://github.com/gokcehan/lf/tree/master/etc) .PP -.EX - cmd on-cd &{{ - bash -c ' - # display git repository status in your prompt - source /usr/share/git/completion/git-prompt.sh - GIT_PS1_SHOWDIRTYSTATE=auto - GIT_PS1_SHOWSTASHSTATE=auto - GIT_PS1_SHOWUNTRACKEDFILES=auto - GIT_PS1_SHOWUPSTREAM=auto - git=$(__git_ps1 " (%s)") - fmt="\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f$git\e033[0m" - lf -remote "send $id set promptfmt \e"$fmt\e"" - ' - }} -.EE +There is a special command \f[C]on\-cd\f[R] that runs a shell command +when it is defined and the directory is changed. +You can define it just as you would define any other command: +.IP +.nf +\f[C] +cmd on\-cd &{{ + bash \-c \[aq] + # display git repository status in your prompt + source /usr/share/git/completion/git\-prompt.sh + GIT_PS1_SHOWDIRTYSTATE=auto + GIT_PS1_SHOWSTASHSTATE=auto + GIT_PS1_SHOWUNTRACKEDFILES=auto + GIT_PS1_SHOWUPSTREAM=auto + git=$(__git_ps1 \[dq] (%s)\[dq]) + fmt=\[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f$git\[rs]033[0m\[dq] + lf \-remote \[dq]send $id set promptfmt \[rs]\[dq]$fmt\[rs]\[dq]\[dq] + \[aq] +}} +\f[R] +.fi .PP -If you want to print escape sequences, you may redirect 'printf' output to '/dev/tty'. The following xterm specific escape sequence sets the terminal title to the working directory: +If you want to print escape sequences, you may redirect \f[C]printf\f[R] +output to \f[C]/dev/tty\f[R]. +The following xterm specific escape sequence sets the terminal title to +the working directory: +.IP +.nf +\f[C] +cmd on\-cd &{{ + printf \[dq]\[rs]033]0; $PWD\[rs]007\[dq] > /dev/tty +}} +\f[R] +.fi .PP -.EX - cmd on-cd &{{ - printf "\e033]0; $PWD\e007" > /dev/tty - }} -.EE +This command runs whenever you change directory but not on startup. +You can add an extra call to make it run on startup as well: +.IP +.nf +\f[C] +cmd on\-cd &{{ ... }} +on\-cd +\f[R] +.fi .PP -This command runs whenever you change directory but not on startup. You can add an extra call to make it run on startup as well: +Note that all shell commands are possible but \f[C]%\f[R] and +\f[C]&\f[R] are usually more appropriate as \f[C]$\f[R] and \f[C]!\f[R] +causes flickers and pauses respectively. .PP -.EX - cmd on-cd &{{ ... }} - on-cd -.EE -.PP -Note that all shell commands are possible but '%' and '&' are usually more appropriate as '$' and '!' causes flickers and pauses respectively. -.PP -There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed. +There is also a \f[C]pre\-cd\f[R] command, that works like +\f[C]on\-cd\f[R], but is run before the directory is actually changed. .SH COLORS -lf tries to automatically adapt its colors to the environment. It starts with a default colorscheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order: .PP -.EX - 1. default - 2. LSCOLORS (Mac/BSD ls) - 3. LS_COLORS (GNU ls) - 4. LF_COLORS (lf specific) - 5. colors file (lf specific) -.EE +lf tries to automatically adapt its colors to the environment. +It starts with a default colorscheme and updates colors using values of +existing environment variables possibly by overwriting its previous +values. +Colors are set in the following order: +.IP "1." 3 +default +.IP "2." 3 +LSCOLORS (Mac/BSD ls) +.IP "3." 3 +LS_COLORS (GNU ls) +.IP "4." 3 +LF_COLORS (lf specific) +.IP "5." 3 +colors file (lf specific) .PP -Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls. This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases. Colors file is provided for easier configuration without environment variables. This file should consist of whitespace separated pairs with '#' character to start comments until the end of line. +Please refer to the corresponding man pages for more information about +\f[C]LSCOLORS\f[R] and \f[C]LS_COLORS\f[R]. +\f[C]LF_COLORS\f[R] is provided with the same syntax as +\f[C]LS_COLORS\f[R] in case you want to configure colors only for lf but +not ls. +This can be useful since there are some differences between ls and lf, +though one should expect the same behavior for common cases. +Colors file is provided for easier configuration without environment +variables. +This file should consist of whitespace separated pairs with \f[C]#\f[R] +character to start comments until the end of line. .PP -You can configure lf colors in two different ways. First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other. +You can configure lf colors in two different ways. +First, you can only configure 8 basic colors used by your terminal and +lf should pick up those colors automatically. +Depending on your terminal, you should be able to select your colors +from a 24\-bit palette. +This is the recommended approach as colors used by other programs will +also match each other. .PP -Second, you can set the values of environment variables or colors file mentioned above for fine grained customization. Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results. +Second, you can set the values of environment variables or colors file +mentioned above for fine grained customization. +Note that \f[C]LS_COLORS/LF_COLORS\f[R] are more powerful than +\f[C]LSCOLORS\f[R] and they can be used even when GNU programs are not +installed on the system. +You can combine this second method with the first method for best +results. .PP -Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes. See the default value of this option to have an idea about how to color this line. +Lastly, you may also want to configure the colors of the prompt line to +match the rest of the colors. +Colors of the prompt line can be configured using the +\f[C]promptfmt\f[R] option which can include hardcoded colors as ansi +escapes. +See the default value of this option to have an idea about how to color +this line. .PP -It is worth noting that lf uses as many colors advertised by your terminal's entry in terminfo or infocmp databases on your system. If an entry is not present, it falls back to an internal database. If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the '$COLORTERM' variable to 'truecolor' or ensuring '$TERM' is set to a value that ends with '-truecolor'. +It is worth noting that lf uses as many colors advertised by your +terminal\[aq]s entry in terminfo or infocmp databases on your system. +If an entry is not present, it falls back to an internal database. +If your terminal supports 24\-bit colors but either does not have a +database entry or does not advertise all capabilities, you can enable +support by setting the \f[C]$COLORTERM\f[R] variable to +\f[C]truecolor\f[R] or ensuring \f[C]$TERM\f[R] is set to a value that +ends with \f[C]\-truecolor\f[R]. .PP -Default lf colors are mostly taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute. Default dircolors entries with background colors are simplified to avoid confusion with current file selection in lf. Similarly, there are only file type matchings and extension matchings are left out for simplicity. Default values are as follows given with their matching order in lf: +Default lf colors are mostly taken from GNU dircolors defaults. +These defaults use 8 basic colors and bold attribute. +Default dircolors entries with background colors are simplified to avoid +confusion with current file selection in lf. +Similarly, there are only file type matchings and extension matchings +are left out for simplicity. +Default values are as follows given with their matching order in lf: +.IP +.nf +\f[C] +ln 01;36 +or 31;01 +tw 01;34 +ow 01;34 +st 01;34 +di 01;34 +pi 33 +so 01;35 +bd 33;01 +cd 33;01 +su 01;32 +sg 01;32 +ex 01;32 +fi 00 +\f[R] +.fi .PP -.EX - ln 01;36 - or 31;01 - tw 01;34 - ow 01;34 - st 01;34 - di 01;34 - pi 33 - so 01;35 - bd 33;01 - cd 33;01 - su 01;32 - sg 01;32 - ex 01;32 - fi 00 -.EE +Note that lf first tries matching file names and then falls back to file +types. +The full order of matchings from most specific to least are as follows: +.IP "1." 3 +Full Path (e.g. +\f[C]\[ti]/.config/lf/lfrc\f[R]) +.IP "2." 3 +Dir Name (e.g. +\f[C].git/\f[R]) (only matches dirs with a trailing slash at the end) +.IP "3." 3 +File Type (e.g. +\f[C]ln\f[R]) (except \f[C]fi\f[R]) +.IP "4." 3 +File Name (e.g. +\f[C]README*\f[R]) +.IP "5." 3 +File Name (e.g. +\f[C]*README\f[R]) +.IP "6." 3 +Base Name (e.g. +\f[C]README.*\f[R]) +.IP "7." 3 +Extension (e.g. +\f[C]*.txt\f[R]) +.IP "8." 3 +Default (i.e. +\f[C]fi\f[R]) .PP -Note that lf first tries matching file names and then falls back to file types. The full order of matchings from most specific to least are as follows: +For example, given a regular text file \f[C]/path/to/README.txt\f[R], +the following entries are checked in the configuration and the first one +to match is used: +.IP "1." 3 +\f[C]/path/to/README.txt\f[R] +.IP "2." 3 +(skipped since the file is not a directory) +.IP "3." 3 +(skipped since the file is of type \f[C]fi\f[R]) +.IP "4." 3 +\f[C]README.txt*\f[R] +.IP "5." 3 +\f[C]*README.txt\f[R] +.IP "6." 3 +\f[C]README.*\f[R] +.IP "7." 3 +\f[C]*.txt\f[R] +.IP "8." 3 +\f[C]fi\f[R] .PP -.EX - 1. Full Path (e.g. '~/.config/lf/lfrc') - 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Type (e.g. 'ln') (except 'fi') - 4. File Name (e.g. 'README*') - 5. File Name (e.g. '*README') - 6. Base Name (e.g. 'README.*') - 7. Extension (e.g. '*.txt') - 8. Default (i.e. 'fi') -.EE +Given a regular directory \f[C]/path/to/example.d\f[R], the following +entries are checked in the configuration and the first one to match is +used: +.IP "1." 3 +\f[C]/path/to/example.d\f[R] +.IP "2." 3 +\f[C]example.d/\f[R] +.IP "3." 3 +\f[C]di\f[R] +.IP "4." 3 +\f[C]example.d*\f[R] +.IP "5." 3 +\f[C]*example.d\f[R] +.IP "6." 3 +\f[C]example.*\f[R] +.IP "7." 3 +\f[C]*.d\f[R] +.IP "8." 3 +\f[C]fi\f[R] .PP -For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used: -.PP -.EX - 1. '/path/to/README.txt' - 2. (skipped since the file is not a directory) - 3. (skipped since the file is of type 'fi') - 4. 'README.txt*' - 5. '*README.txt' - 6. 'README.*' - 7. '*.txt' - 8. 'fi' -.EE -.PP -Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used: -.PP -.EX - 1. '/path/to/example.d' - 2. 'example.d/' - 3. 'di' - 4. 'example.d*' - 5. '*example.d' - 6. 'example.*' - 7. '*.d' - 8. 'fi' -.EE -.PP -Note that glob-like patterns do not actually perform glob matching due to performance reasons. +Note that glob\-like patterns do not actually perform glob matching due +to performance reasons. .PP For example, you can set a variable as follows: +.IP +.nf +\f[C] +export LF_COLORS=\[dq]\[ti]/Documents=01;31:\[ti]/Downloads=01;31:\[ti]/.local/share=01;31:\[ti]/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:\[dq] +\f[R] +.fi .PP -.EX - export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:" -.EE +Having all entries on a single line can make it hard to read. +You may instead divide it to multiple lines in between double quotes by +escaping newlines with backslashes as follows: +.IP +.nf +\f[C] +export LF_COLORS=\[dq]\[rs] +\[ti]/Documents=01;31:\[rs] +\[ti]/Downloads=01;31:\[rs] +\[ti]/.local/share=01;31:\[rs] +\[ti]/.config/lf/lfrc=31:\[rs] +\&.git/=01;32:\[rs] +\&.git*=32:\[rs] +*.gitignore=32:\[rs] +*Makefile=32:\[rs] +README.*=33:\[rs] +*.txt=34:\[rs] +*.md=34:\[rs] +ln=01;36:\[rs] +di=01;34:\[rs] +ex=01;32:\[rs] +\[dq] +\f[R] +.fi .PP -Having all entries on a single line can make it hard to read. You may instead divide it to multiple lines in between double quotes by escaping newlines with backslashes as follows: -.PP -.EX - export LF_COLORS="\e - ~/Documents=01;31:\e - ~/Downloads=01;31:\e - ~/.local/share=01;31:\e - ~/.config/lf/lfrc=31:\e - .git/=01;32:\e - .git*=32:\e - *.gitignore=32:\e - *Makefile=32:\e - README.*=33:\e - *.txt=34:\e - *.md=34:\e - ln=01;36:\e - di=01;34:\e - ex=01;32:\e - " -.EE -.PP -Having such a long variable definition in a shell configuration file might be undesirable. You may instead use the colors file for configuration. A sample colors file can be found at https://github.com/gokcehan/lf/blob/master/etc/colors.example You may also see the wiki page for ansi escape codes https://en.wikipedia.org/wiki/ANSI_escape_code +Having such a long variable definition in a shell configuration file +might be undesirable. +You may instead use the colors file for configuration. +A sample colors file can be found at +https://github.com/gokcehan/lf/blob/master/etc/colors.example (https://github.com/gokcehan/lf/blob/master/etc/colors.example) +You may also see the wiki page for ansi escape codes +https://en.wikipedia.org/wiki/ANSI_escape_code (https://en.wikipedia.org/wiki/ANSI_escape_code) .SH ICONS -Icons are configured using 'LF_ICONS' environment variable or an icons file. The variable uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of colors, you should put a single characters as values of entries. Icons file should consist of whitespace separated pairs with '#' character to start comments until the end of line. Do not forget to enable 'icons' option to see the icons. Default values are as follows given with their matching order in lf: .PP -.EX - ln l - or l - tw t - ow d - st t - di d - pi p - so s - bd b - cd c - su u - sg g - ex x - fi - -.EE +Icons are configured using \f[C]LF_ICONS\f[R] environment variable or an +icons file. +The variable uses the same syntax as \f[C]LS_COLORS/LF_COLORS\f[R]. +Instead of colors, you should put a single characters as values of +entries. +Icons file should consist of whitespace separated pairs with \f[C]#\f[R] +character to start comments until the end of line. +Do not forget to enable \f[C]icons\f[R] option to see the icons. +Default values are as follows given with their matching order in lf: +.IP +.nf +\f[C] +ln l +or l +tw t +ow d +st t +di d +pi p +so s +bd b +cd c +su u +sg g +ex x +fi \- +\f[R] +.fi .PP -A sample icons file can be found at https://github.com/gokcehan/lf/blob/master/etc/icons.example +A sample icons file can be found at +https://github.com/gokcehan/lf/blob/master/etc/icons.example (https://github.com/gokcehan/lf/blob/master/etc/icons.example) diff --git a/main.go b/main.go index ad88a822..013c92d1 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,11 @@ import ( "strings" ) +import _ "embed" + +//go:embed doc.txt +var genDocString string + var ( envPath = os.Getenv("PATH") envLevel = os.Getenv("LF_LEVEL")