From 654b8737b8a35729aa89aa93acf05ed5871b2616 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 15 Oct 2022 21:34:55 +0300 Subject: [PATCH] update man generator for go1.19 cc #959 #961 --- app.go | 10 +- doc.go | 1200 +++++++++++++++++++++++++------------------------- docstring.go | 928 +++++++++++++++++++------------------- gen/man.sh | 3 +- lf.1 | 67 +-- 5 files changed, 1090 insertions(+), 1118 deletions(-) diff --git a/app.go b/app.go index 72e59d81..627fcafc 100644 --- a/app.go +++ b/app.go @@ -470,11 +470,11 @@ func (app *app) loop() { // This function is used to run a shell command. Modes are as follows: // -// Prefix Wait Async Stdin Stdout Stderr UI action -// $ No No Yes Yes Yes Pause and then resume -// % No No Yes Yes Yes Statline for input/output -// ! Yes No Yes Yes Yes Pause and then resume -// & No Yes No No No Do nothing +// Prefix Wait Async Stdin Stdout Stderr UI action +// $ No No Yes Yes Yes Pause and then resume +// % No No Yes Yes Yes Statline for input/output +// ! Yes No Yes Yes Yes Pause and then resume +// & No Yes No No No Do nothing func (app *app) runShell(s string, args []string, prefix string) { app.nav.exportFiles() exportOpts() diff --git a/doc.go b/doc.go index 33930721..e78d41f3 100644 --- a/doc.go +++ b/doc.go @@ -12,571 +12,571 @@ A man page with the same content is also available in the repository at https:// You can run 'lf -help' to see descriptions of command line options. -Quick Reference +# 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') - unselect (default 'u') - glob-select - glob-unselect - calcdirsize - 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') + 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') + unselect (default 'u') + glob-select + glob-unselect + calcdirsize + 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 '') - cmd-history-prev (default '') - 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-capitalize-word (default '') - cmd-uppercase-word (default '') - cmd-lowercase-word (default '') + 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 '') + cmd-history-prev (default '') + 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-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 on) - autoquit bool (default off) - cleaner string (default '') - dircache bool (default on) - dircounts bool (default off) - dirfirst bool (default on) - dironly bool (default off) - dirpreviews bool (default off) - drawbox bool (default off) - errorfmt string (default "\033[7;31;47m%s\033[0m") - filesep string (default "\n") - findlen int (default 1) - globsearch bool (default off) - hidden bool (default off) - hiddenfiles []string (default '.*') - history bool (default on) - icons bool (default off) - ifs string (default '') - ignorecase bool (default on) - ignoredia bool (default on) - incfilter bool (default off) - incsearch bool (default off) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default off) - number bool (default off) - period int (default 0) - preview bool (default on) - 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 off) - reverse bool (default off) - 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 '') - smartcase bool (default on) - smartdia bool (default off) - sortby string (default 'natural') - tabstop int (default 8) - tagfmt string (default "\033[31m%s\033[0m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - waitmsg string (default 'Press any key to continue') - wrapscan bool (default on) - wrapscroll bool (default off) - user_{key} string (default none) + anchorfind bool (default on) + autoquit bool (default off) + cleaner string (default '') + dircache bool (default on) + dircounts bool (default off) + dirfirst bool (default on) + dironly bool (default off) + dirpreviews bool (default off) + drawbox bool (default off) + errorfmt string (default "\033[7;31;47m%s\033[0m") + filesep string (default "\n") + findlen int (default 1) + globsearch bool (default off) + hidden bool (default off) + hiddenfiles []string (default '.*') + history bool (default on) + icons bool (default off) + ifs string (default '') + ignorecase bool (default on) + ignoredia bool (default on) + incfilter bool (default off) + incsearch bool (default off) + info []string (default '') + infotimefmtnew string (default 'Jan _2 15:04') + infotimefmtold string (default 'Jan _2 2006') + mouse bool (default off) + number bool (default off) + period int (default 0) + preview bool (default on) + 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 off) + reverse bool (default off) + 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 '') + smartcase bool (default on) + smartdia bool (default off) + sortby string (default 'natural') + tabstop int (default 8) + tagfmt string (default "\033[31m%s\033[0m") + tempmarks string (default '') + timefmt string (default 'Mon Jan _2 15:04:05 2006') + truncatechar string (default '~') + waitmsg string (default 'Press any key to continue') + wrapscan bool (default on) + wrapscroll bool (default off) + user_{key} string (default none) The following environment variables are exported for shell commands: - f - fs - fx - id - PWD - OLDPWD - LF_LEVEL - OPENER - EDITOR - PAGER - SHELL - lf_{option} - lf_user_{key} + f + fs + fx + id + PWD + OLDPWD + LF_LEVEL + OPENER + EDITOR + PAGER + SHELL + lf_{option} + lf_user_{key} 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-quit + open + paste + rename + delete + pre-cd + on-cd + on-select + on-quit The following commands/keybindings are provided by default: - Unix Windows - cmd open &$OPENER "$f" cmd open &%OPENER% %f% - map e $$EDITOR "$f" map e $%EDITOR% %f% - map i $$PAGER "$f" map i !%PAGER% %f% - map w $$SHELL map w $%SHELL% + Unix Windows + cmd open &$OPENER "$f" cmd open &%OPENER% %f% + map e $$EDITOR "$f" map e $%EDITOR% %f% + map i $$PAGER "$f" map i !%PAGER% %f% + map w $$SHELL map w $%SHELL% 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 + 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 -Configuration +# 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 + 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 + 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 + 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 + 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 + 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 + 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 + Unix ~/.local/share/lf/history + Windows C:\Users\\AppData\Local\lf\history You can configure the default values of following variables to change these locations: - $XDG_CONFIG_HOME ~/.config - $XDG_DATA_HOME ~/.local/share - %ProgramData% C:\ProgramData - %LOCALAPPDATA% C:\Users\\AppData\Local + $XDG_CONFIG_HOME ~/.config + $XDG_DATA_HOME ~/.local/share + %ProgramData% C:\ProgramData + %LOCALAPPDATA% C:\Users\\AppData\Local 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. - 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. - 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). 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. - 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 '-'. - 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. - 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. - 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. - 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. - 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. - 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. - 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-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. -Command Line Commands +# Command Line Commands This section shows information about command line commands. These 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 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 '') - cmd-history-prev (default '') + cmd-history-next (default '') + cmd-history-prev (default '') 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-back (default '' and '') + cmd-delete (default '' and '') + cmd-delete-back (default '' and '') Delete the next character in forward/backward direction. - 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-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'. - anchorfind bool (default on) + anchorfind bool (default on) 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 off) + autoquit bool (default off) Automatically quit server when there are no clients left connected. - 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. @@ -584,11 +584,11 @@ This file is called if previewing is enabled, the previewer is set, and the prev 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. Preview clearing is disabled when the value of this option is left empty. - dircache bool (default on) + dircache bool (default on) Cache directory contents. - dircounts bool (default off) + dircounts bool (default off) 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. @@ -596,63 +596,63 @@ 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 on) + dirfirst bool (default on) Show directories first above regular files. - dironly bool (default off) + dironly bool (default off) If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. - dirpreviews bool (default off) + dirpreviews bool (default off) Show only directories. - drawbox bool (default off) + drawbox bool (default off) Draw boxes around panes with box drawing characters. - errorfmt string (default "\033[7;31;47m%s\033[0m") + errorfmt string (default "\033[7;31;47m%s\033[0m") Format string of error messages shown in the bottom message line. - filesep string (default "\n") + filesep string (default "\n") 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 off) + globsearch bool (default off) 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 off) + hidden bool (default off) 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 '.*') + 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. - history bool (default on) + history bool (default on) Save command history. - icons bool (default off) + icons bool (default off) 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='...'; ...". @@ -661,46 +661,46 @@ 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 on) + ignorecase bool (default on) Ignore case in sorting and search patterns. - ignoredia bool (default on) + ignoredia bool (default on) Ignore diacritics in sorting and search patterns. - incsearch bool (default off) + incsearch bool (default off) Jump to the first match after each keystroke during searching. - incfilter bool (default off) + incfilter bool (default off) 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'. 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 off) + mouse bool (default off) Send mouse events as input. - number bool (default off) + number bool (default off) 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. - 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. @@ -708,13 +708,13 @@ 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. - preview bool (default on) + preview bool (default on) 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) + 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. @@ -724,329 +724,333 @@ 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. 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. - relativenumber bool (default off) + relativenumber bool (default off) 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 off) + reverse bool (default off) Reverse the direction of sort. - 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. - 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'. - 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. - smartcase bool (default on) + smartcase bool (default on) Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled. - smartdia bool (default off) + smartdia bool (default off) 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'. - 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%s\033[0m") + tagfmt string (default "\033[31m%s\033[0m") Format string of the tags. - tempmarks string (default '') + 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') + 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. - 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 on) + wrapscan bool (default on) Searching can wrap around the file list. - wrapscroll bool (default off) + wrapscroll bool (default off) Scrolling can wrap around the file list. - user_{key} string (default none) + user_{key} 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_{key}` environment variable. These options are not used by lf and are not persisted. +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_{key}` 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'). - 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). - fx + fx 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'). - OPENER + OPENER If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. - EDITOR + EDITOR If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows. - PAGER + PAGER If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows. - SHELL + SHELL If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows. - lf_{option} + lf_{option} Value of the {option}. -Special Commands +# Special Commands - open +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 + paste 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. - delete + delete 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-quit + on-quit This shell command can be defined to be executed before quit. -Prefixes +# 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 + : 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 +# Syntax Characters from '#' to newline are comments and ignored: - # comments start with '#' + # comments start with '#' There are four special commands ('set', 'map', 'cmap', and 'cmd') for configuration. Command 'set' is used to set an option which can be boolean, integer, or string: - set hidden # boolean on - set nohidden # boolean off - 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) + set hidden # boolean on + set nohidden # boolean off + 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 '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 + 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! + 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 + map gh # deletes 'gh' mapping + cmap # deletes '' mapping Command 'cmd' is used to define a custom command: - cmd usage $du -h -d1 | less + cmd usage $du -h -d1 | less You can delete an existing command by leaving the expression empty: - cmd trash # deletes 'trash' command + cmd trash # deletes 'trash' command If there is no prefix then ':' is assumed: - map zt set info time + 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 + 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 - }} + map st :{{ + set sortby time + set info time + }} -Key Mappings +# Key Mappings Regular keys are assigned to a command with the usual syntax: - map a down + map a down Keys combined with the shift key simply use the uppercase letter: - map A down + map A down Special keys are written in between '<' and '>' characters and always use lowercase letters: - map down + map down Angle brackets can be assigned with their special names: - map down - map down + map down + map down Function keys are prefixed with 'f' character: - map down + map down Keys combined with the control key are prefixed with 'c' character: - map down + 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 + 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 + map down Please note that, some key combinations are not possible due to the way terminals work (e.g. control and h combination sends a backspace key instead). The easiest way to find the name of a key combination is to press the key while lf is running and read the name of the key 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 + 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 + 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. @@ -1057,55 +1061,55 @@ You can 'map' a key to a 'push' command with an argument to create various keybi This is mainly useful for two purposes. First, it can be used to map a command with a command count: - map push 10j + map push 10j Second, it can be used to avoid typing the name when a command takes arguments: - map r push :rename + 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 + 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. 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 - }} + 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 - }} + 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 }} + ${{ mkdir -p ~/.trash }} - cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} + cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} Since these are one liners, we can drop '{{' and '}}': - $mkdir -p ~/.trash + $mkdir -p ~/.trash - cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.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"'). @@ -1113,7 +1117,7 @@ This can be especially useful for interactive use (e.g. '$rm $f' or '$rm $fs' wo 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. @@ -1125,27 +1129,27 @@ This can be useful for programs following the Unix philosophy to give no output 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 + 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 + 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 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. @@ -1156,18 +1160,18 @@ To use this feature, you need to use a client which supports communicating with 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 + 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' + 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' + 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. @@ -1175,31 +1179,31 @@ 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" + 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 %{{ - w=$(tput cols) - if [ $w -le 80 ]; then - lf -remote "send $id set ratios 1:2" - elif [ $w -le 160 ]; then - lf -remote "send $id set ratios 1:2:3" - else - lf -remote "send $id set ratios 1:2:3:5" - fi - }} + cmd recol %{{ + w=$(tput cols) + if [ $w -le 80 ]; then + lf -remote "send $id set ratios 1:2" + elif [ $w -le 160 ]; then + lf -remote "send $id set ratios 1:2:3" + else + lf -remote "send $id set ratios 1:2:3:5" + fi + }} Besides 'send' command, there is 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!' + 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 +# 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. @@ -1220,18 +1224,18 @@ 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 - }} + 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. @@ -1240,7 +1244,7 @@ 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. @@ -1254,7 +1258,7 @@ In this mode, you can either use 'cmd-enter' to accept the search or use 'cmd-es 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 + 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. @@ -1269,37 +1273,37 @@ This option is already automatically overridden if the pattern contains upper ca 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. 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 + cmd open $vi $fx It is possible to use different command types: - cmd open &xdg-open $f + 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 - }} + 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. Following command is provided by default: - cmd open &$OPENER $f + 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 +# 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. @@ -1311,28 +1315,28 @@ Five arguments are passed to the file, (1) current file name, (2) width, (3) hei 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 + 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 + set previewer ~/.config/lf/pv.sh + map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user. You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from 'file' command. Extensions can then be used to match cleanly within a conditional: - #!/bin/sh + #!/bin/sh - 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 + 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. @@ -1343,14 +1347,14 @@ When everything else fails, you can make use of the height argument to only feed 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 + 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 +# 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. @@ -1360,46 +1364,46 @@ 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 &{{ - # 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)") || true - 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\"" - }} + cmd on-cd &{{ + # 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)") || true + 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 - }} + 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 + 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 +# 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) + 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. @@ -1430,80 +1434,80 @@ Default dircolors entries with background colors are simplified to avoid confusi 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 + 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') + 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' + 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' + 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:" + 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:\ - " + 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. @@ -1512,7 +1516,7 @@ 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'. @@ -1521,20 +1525,20 @@ Icons file should consist of whitespace separated pairs with '#' character to st 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 - + 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 index 5b9ad84b..9579d64c 100644 --- a/docstring.go +++ b/docstring.go @@ -9,14 +9,13 @@ 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 +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 +# Quick Reference The following commands are provided by lf: @@ -122,6 +121,7 @@ The following options can be used to customize the behavior of lf: dircounts bool (default off) dirfirst bool (default on) dironly bool (default off) + dirpreviews bool (default off) drawbox bool (default off) errorfmt string (default "\033[7;31;47m%s\033[0m") filesep string (default "\n") @@ -182,8 +182,8 @@ The following environment variables are exported for shell commands: lf_{option} lf_user_{key} -The following special shell commands are used to customize the behavior of -lf when defined: +The following special shell commands are used to customize the behavior of lf +when defined: open paste @@ -219,8 +219,7 @@ The following additional keybindings are provided by default: map gh cd ~ map :toggle; down - -Configuration +# Configuration Configuration files should be located at: @@ -271,12 +270,11 @@ locations: 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. +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') @@ -291,8 +289,8 @@ Quit lf and return to the shell. page-down (default '' and '') scroll-down (default '') -Move/scroll the current file selection upwards/downwards by one/half a -page/full page. +Move/scroll the current file selection upwards/downwards by one/half a page/full +page. updir (default 'h' and '') @@ -302,9 +300,8 @@ Change the current working directory to the parent directory. 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. +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 '[') @@ -329,10 +326,10 @@ 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. +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. unselect (default 'u') @@ -347,8 +344,8 @@ Select/unselect files that match the given glob. 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 '-'. +size. If the total size of a directory is not calculated, it will be shown as +'-'. copy (default 'y') @@ -357,13 +354,13 @@ 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. +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. +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') @@ -371,8 +368,8 @@ Clear file paths in copy/cut buffer. sync -Synchronize copied/cut files with server. This command is automatically -called when required. +Synchronize copied/cut files with server. This command is automatically called +when required. draw @@ -384,8 +381,8 @@ Synchronize the terminal and redraw the screen. load -Load modified files and directories. This command is automatically called -when required. +Load modified files and directories. This command is automatically called when +required. reload (default '') @@ -402,8 +399,8 @@ file. 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 @@ -415,13 +412,13 @@ 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. +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. +Rename the current file using the builtin method. A custom 'rename' command can +be defined to override this default. source @@ -441,8 +438,7 @@ 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. +Read a shell command to execute piping its standard I/O to the bottom statline. shell-wait (modal) (default '!') @@ -465,16 +461,16 @@ direction and jump to the next/previous match. 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. +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. +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') @@ -482,8 +478,8 @@ 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', +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 '"') @@ -492,22 +488,21 @@ 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 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 +# Command Line Commands This section shows information about command line commands. These 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. +code point, a word consists of letters and digits, and a unix word consists of +any non-blank characters. cmd-escape (default '') @@ -520,10 +515,10 @@ 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. +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 @@ -590,12 +585,10 @@ Delete the next word in forward direction. 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 on) @@ -610,10 +603,10 @@ Automatically quit server when there are no clients left connected. 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. 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. Preview -clearing is disabled when the value of this option is left empty. +selected file had its preview cache disabled. 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. Preview clearing is +disabled when the value of this option is left empty. dircache bool (default on) @@ -623,12 +616,12 @@ Cache directory contents. 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+'. +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 on) @@ -636,6 +629,11 @@ Show directories first above regular files. dironly bool (default off) +If enabled, directories will also be passed to the previewer script. This allows +custom previews for directories. + + dirpreviews bool (default off) + Show only directories. drawbox bool (default off) @@ -652,29 +650,29 @@ 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. +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 off) -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. +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 off) 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. +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. +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. history bool (default on) @@ -686,12 +684,12 @@ 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. +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 on) @@ -712,9 +710,9 @@ 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. +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') @@ -723,8 +721,8 @@ 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. +Format string of the file time shown in the info column when it doesn't match +this year. mouse bool (default off) @@ -738,54 +736,53 @@ position and relative positions are shown for the rest. 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. +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. preview bool (default on) 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'. +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. 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. 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. +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. +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. +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 off) -Show the position number relative to the current line. When 'number' is -enabled, current line shows the absolute position, otherwise nothing is -shown. +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 off) @@ -793,17 +790,17 @@ Reverse the direction of sort. 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. +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. +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) @@ -820,8 +817,8 @@ List of shell options to pass to the shell executable. smartcase bool (default on) -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 off) @@ -830,13 +827,12 @@ 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'. +Sort type for directories. Currently supported sort types are 'natural', 'name', +'size', 'time', 'ctime', 'atime', and 'ext'. tabstop int (default 8) -Number of space characters to show for horizontal tabulation (U+0009) -character. +Number of space characters to show for horizontal tabulation (U+0009) character. tagfmt string (default "\033[31m%s\033[0m") @@ -844,9 +840,9 @@ Format string of the tags. 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 +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') @@ -855,8 +851,7 @@ 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. +Truncate character shown at the end when the file name does not fit to the pane. waitmsg string (default 'Press any key to continue') @@ -872,18 +867,16 @@ Scrolling can wrap around the file list. user_{key} 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_{key}' environment variable. These options are not used by -lf and are not persisted. +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_{key}' 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'). +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 @@ -891,13 +884,12 @@ Current file selection as a full path. 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 -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 @@ -915,41 +907,42 @@ Initial working directory. 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'). +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 -set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. +If this variable is set in the environment, use the same value, otherwise set +the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. EDITOR -If this variable is set in the environment, use the same value, otherwise -set the value to 'vi' on Unix, 'notepad' in Windows. +If this variable is set in the environment, use the same value, otherwise set +the value to 'vi' on Unix, 'notepad' in Windows. PAGER -If this variable is set in the environment, use the same value, otherwise -set the value to 'less' on Unix, 'more' in Windows. +If this variable is set in the environment, use the same value, otherwise set +the value to 'less' on Unix, 'more' in Windows. SHELL -If this variable is set in the environment, use the same value, otherwise -set the value to 'sh' on Unix, 'cmd' in Windows. +If this variable is set in the environment, use the same value, otherwise set +the value to 'sh' on Unix, 'cmd' in Windows. lf_{option} Value of the {option}. -Special Commands +# 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. +This shell command can be defined to override the default 'open' command when +the current file is not a directory. paste @@ -965,8 +958,7 @@ 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. +This shell command can be defined to be executed before changing a directory. on-cd @@ -974,15 +966,13 @@ 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. +This shell command can be defined to be executed after the selection changes. on-quit This shell command can be defined to be executed before quit. - -Prefixes +# Prefixes The following command prefixes are used by lf: @@ -992,14 +982,12 @@ The following command prefixes are used by lf: ! 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. +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 +# Syntax Characters from '#' to newline are comments and ignored: @@ -1008,8 +996,7 @@ Characters from '#' to newline are comments and ignored: There are four special commands ('set', '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 on set nohidden # boolean off @@ -1019,8 +1006,8 @@ string: set sortby 'time' # string value with single quotes (whitespaces) set sortby "time" # string value with double quotes (backslash escapes) -Command 'map' is used to bind a key to a command which can be builtin -command, custom command, or shell command: +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 @@ -1055,16 +1042,15 @@ 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: @@ -1092,25 +1078,24 @@ 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: +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: +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 Please note that, some key combinations are not possible due to the way -terminals work (e.g. control and h combination sends a backspace key -instead). The easiest way to find the name of a key combination is to press -the key while lf is running and read the name of the key from the unknown -mapping error. +terminals work (e.g. control and h combination sends a backspace key instead). +The easiest way to find the name of a key combination is to press the key while +lf is running and read the name of the key from the unknown mapping error. Mouse buttons are prefixed with 'm' character: @@ -1130,40 +1115,36 @@ Mouse wheel events are also prefixed with 'm' character: 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. 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. +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: +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: +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. A first attempt to write such a command may look like -this: +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 @@ -1174,18 +1155,17 @@ this: 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: +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: +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 }} @@ -1197,31 +1177,29 @@ Since these are one liners, we can drop '{{' and '}}': 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 +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. +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. -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 +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: +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 @@ -1232,64 +1210,59 @@ statline. 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. -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. -Asynchronous Shell Commands +# Remote 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. +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. - -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: +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: +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: +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: +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: +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 %{{ w=$(tput cols) @@ -1302,43 +1275,40 @@ with respect to the terminal width as follows: fi }} -Besides 'send' command, there is 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: +Besides 'send' command, there is 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. +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. Only file modes -are preserved and all other attributes are ignored including ownership, -timestamps, 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. +option in GNU cp is added to the new files or directories. Only file modes are +preserved and all other attributes are ignored including ownership, timestamps, +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. +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: +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) @@ -1353,63 +1323,61 @@ 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. 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 '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. +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: +(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. +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. +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 -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: +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 @@ -1417,8 +1385,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 @@ -1434,41 +1401,40 @@ 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. +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 +# 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. +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: +(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: +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: +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 @@ -1481,39 +1447,37 @@ match cleanly within a conditional: *) 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: +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. +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 +# 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 +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: +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 &{{ # display git repository status in your prompt @@ -1528,15 +1492,15 @@ define any other command: }} 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: +'/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: +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 @@ -1544,64 +1508,61 @@ add an extra call to make it run on startup as well: 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. Colors are set in the +following order: -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) + 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. +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. +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. +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. +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'. +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: +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 @@ -1618,42 +1579,41 @@ with their matching order in lf: 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: +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: - 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' + 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' + 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. @@ -1662,9 +1622,9 @@ 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: +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:\ @@ -1683,23 +1643,21 @@ newlines with backslashes as follows: 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 +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 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: +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 diff --git a/gen/man.sh b/gen/man.sh index d929314f..2af92873 100755 --- a/gen/man.sh +++ b/gen/man.sh @@ -58,7 +58,8 @@ BEGIN { } # heading -/^[^[:punct:]]*$/ { +/^# *[^[:punct:]]*$/ { + gsub(/# */, "", $0) print ".SH", toupper($0) start = 1 next diff --git a/lf.1 b/lf.1 index 4ca33bcb..37f91052 100644 --- a/lf.1 +++ b/lf.1 @@ -137,6 +137,7 @@ The following options can be used to customize the behavior of lf: dircounts bool (default off) dirfirst bool (default on) dironly bool (default off) + dirpreviews bool (default off) drawbox bool (default off) errorfmt string (default "\e033[7;31;47m%s\e033[0m") filesep string (default "\en") @@ -740,6 +741,12 @@ Show directories first above regular files. dironly bool (default off) .EE .PP +If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. +.PP +.EX + dirpreviews bool (default off) +.EE +.PP Show only directories. .PP .EX @@ -1074,10 +1081,12 @@ If this variable is set in the environment, use the same value, otherwise set th .PP Value of the {option}. .SH SPECIAL COMMANDS +This section shows information about special shell commands. .PP .EX open .EE +.PP This shell command can be defined to override the default 'open' command when the current file is not a directory. .PP .EX @@ -1572,11 +1581,11 @@ There is also a 'pre-cd' command, that works like 'on-cd', but is run before the 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) + 1. default + 2. LSCOLORS (Mac/BSD ls) + 3. LS_COLORS (GNU ls) + 4. LF_COLORS (lf specific) + 5. colors file (lf specific) .EE .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. @@ -1611,40 +1620,40 @@ Default lf colors are mostly taken from GNU dircolors defaults. These defaults u 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: .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') + 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 .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' + 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' + 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.