From 075caac3a9709777a17a81c0bf8d9b30db674c7b Mon Sep 17 00:00:00 2001 From: Christian Zangl Date: Tue, 26 Dec 2023 15:37:11 +0100 Subject: [PATCH] Add hidecursorinactive option to indicate status when terminal loses focus (#965) * Enable focus events through configuration by using focus (option) and on-ui-enter/on-ui-exit events. * Revert doc This reverts commit 77f113639fbfccdf15b2fe7576c1e173fb50a0f8. * Revert rune evt This reverts commit 77f113639fbfccdf15b2fe7576c1e173fb50a0f8. * hidecursorinactive with tcell * cleanup * cleanup --- client.go | 1 + complete.go | 3 + doc.md | 131 +++++---- doc.txt | 663 ++++++++++++++--------------------------- eval.go | 21 ++ lf.1 | 833 ++++++++++++++++++++++++++-------------------------- opts.go | 128 ++++---- ui.go | 35 ++- 8 files changed, 818 insertions(+), 997 deletions(-) diff --git a/client.go b/client.go index 559102d2..db60df4e 100644 --- a/client.go +++ b/client.go @@ -36,6 +36,7 @@ func run() { if gOpts.mouse { screen.EnableMouse() } + screen.EnableFocus() if gLogPath != "" { f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) diff --git a/complete.go b/complete.go index 984ae046..7c654223 100644 --- a/complete.go +++ b/complete.go @@ -120,6 +120,9 @@ var ( "cursoractivefmt", "cursorparentfmt", "cursorpreviewfmt", + "hidecursorinactive", + "nohidecursorinactive", + "hidecursorinactive!", "dircache", "nodircache", "dircache!", diff --git a/doc.md b/doc.md index 7669b4a7..6910c279 100644 --- a/doc.md +++ b/doc.md @@ -136,69 +136,70 @@ The following command line commands are provided by lf: The following options can be used to customize the behavior of lf: - anchorfind bool (default true) - autoquit bool (default false) - borderfmt string (default "\033[0m") - cleaner string (default '') - cursoractivefmt string (default "\033[7m") - cursorparentfmt string (default "\033[7m") - cursorpreviewfmt string (default "\033[4m") - dircache bool (default true) - dircounts bool (default false) - dirfirst bool (default true) - dironly bool (default false) - dirpreviews bool (default false) - drawbox bool (default false) - dupfilefmt string (default '%f.~%n~') - errorfmt string (default "\033[7;31;47m") - filesep string (default "\n") - findlen int (default 1) - globsearch bool (default false) - hidden bool (default false) - hiddenfiles []string (default '.*') - history bool (default true) - icons bool (default false) - ifs string (default '') - ignorecase bool (default true) - ignoredia bool (default true) - incfilter bool (default false) - incsearch bool (default false) - info []string (default '') - infotimefmtnew string (default 'Jan _2 15:04') - infotimefmtold string (default 'Jan _2 2006') - mouse bool (default false) - number bool (default false) - numberfmt string (default "\033[33m") - period int (default 0) - preserve []string (default "mode") - preview bool (default true) - previewer string (default '') - promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") - ratios []int (default '1:2:3') - relativenumber bool (default false) - reverse bool (default false) - ruler []string (default 'acc:progress:selection:filter:ind') - rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") - scrolloff int (default 0) - selmode string (default 'all') - shell string (default 'sh' for Unix and 'cmd' for Windows) - shellflag string (default '-c' for Unix and '/c' for Windows) - shellopts []string (default '') - sixel bool (default false) - smartcase bool (default true) - smartdia bool (default false) - sortby string (default 'natural') - statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") - tabstop int (default 8) - tagfmt string (default "\033[31m") - tempmarks string (default '') - timefmt string (default 'Mon Jan _2 15:04:05 2006') - truncatechar string (default '~') - truncatepct int (default 100) - waitmsg string (default 'Press any key to continue') - wrapscan bool (default true) - wrapscroll bool (default false) - user_{option} string (default none) + anchorfind bool (default true) + autoquit bool (default false) + borderfmt string (default "\033[0m") + cleaner string (default '') + cursoractivefmt string (default "\033[7m") + cursorparentfmt string (default "\033[7m") + cursorpreviewfmt string (default "\033[4m") + dircache bool (default true) + dircounts bool (default false) + dirfirst bool (default true) + dironly bool (default false) + dirpreviews bool (default false) + drawbox bool (default false) + dupfilefmt string (default '%f.~%n~') + errorfmt string (default "\033[7;31;47m") + filesep string (default "\n") + findlen int (default 1) + globsearch bool (default false) + hidden bool (default false) + hiddenfiles []string (default '.*') + hidecursorinactive bool (default false) + history bool (default true) + icons bool (default false) + ifs string (default '') + ignorecase bool (default true) + ignoredia bool (default true) + incfilter bool (default false) + incsearch bool (default false) + info []string (default '') + infotimefmtnew string (default 'Jan _2 15:04') + infotimefmtold string (default 'Jan _2 2006') + mouse bool (default false) + number bool (default false) + numberfmt string (default "\033[33m") + period int (default 0) + preserve []string (default "mode") + preview bool (default true) + previewer string (default '') + promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") + ratios []int (default '1:2:3') + relativenumber bool (default false) + reverse bool (default false) + ruler []string (default 'acc:progress:selection:filter:ind') + rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t") + scrolloff int (default 0) + selmode string (default 'all') + shell string (default 'sh' for Unix and 'cmd' for Windows) + shellflag string (default '-c' for Unix and '/c' for Windows) + shellopts []string (default '') + sixel bool (default false) + smartcase bool (default true) + smartdia bool (default false) + sortby string (default 'natural') + statfmt string (default "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l") + tabstop int (default 8) + tagfmt string (default "\033[31m") + tempmarks string (default '') + timefmt string (default 'Mon Jan _2 15:04:05 2006') + truncatechar string (default '~') + truncatepct int (default 100) + waitmsg string (default 'Press any key to continue') + wrapscan bool (default true) + wrapscroll bool (default false) + user_{option} string (default none) The following environment variables are exported for shell commands: @@ -755,6 +756,10 @@ Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges. In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak` +## hidecursorinactive (bool) (default false) + +Hide the cursor when the terminal or tmux pane loses focus. + ## history (bool) (default true) Save command history. diff --git a/doc.txt b/doc.txt index 76a0cfda..f93e437a 100644 --- a/doc.txt +++ b/doc.txt @@ -1,44 +1,31 @@ - - NAME - lf - terminal file manager - - SYNOPSIS - -LF [-COMMAND _command_] [-CONFIG _path_] [-CPUPROFILE _path_] [-DOC] -[-LAST-DIR-PATH _path_] [-LOG PATH] [-MEMPROFILE _path_] -[-PRINT-LAST-DIR] [-PRINT-SELECTION] [-REMOTE _command_] -[-SELECTION-PATH _path_] [-SERVER] [-SINGLE] [-VERSION] [-HELP] -[_cd-or-select-path_] - - +lf [-command command] [-config path] [-cpuprofile path] [-doc] +[-last-dir-path path] [-log path] [-memprofile path] [-print-last-dir] +[-print-selection] [-remote command] [-selection-path path] [-server] +[-single] [-version] [-help] [cd-or-select-path] DESCRIPTION - lf is a terminal file manager. -Source code can be found in the repository at +The 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 +This documentation can either be read from the terminal using lf -doc or online at https://github.com/gokcehan/lf/blob/master/doc.md You can also -use doc command (default ) inside lf to view the documentation in a -pager. A man page with the same content is also available in the +use the doc command (default ) inside lf to view the documentation +in a pager. A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1 You can run lf -help to see descriptions of command line options. - - QUICK REFERENCE - The following commands are provided by lf: quit (default 'q') @@ -290,45 +277,42 @@ effects: Scroll wheel Move up or down. If Ctrl is pressed, scroll up or down. - - CONFIGURATION - Configuration files should be located at: OS system-wide user-specific Unix /etc/lf/lfrc ~/.config/lf/lfrc Windows C:\ProgramData\lf\lfrc C:\Users\\AppData\Local\lf\lfrc -Colors file should be located at: +The colors file should be located at: OS system-wide user-specific Unix /etc/lf/colors ~/.config/lf/colors Windows C:\ProgramData\lf\colors C:\Users\\AppData\Local\lf\colors -Icons file should be located at: +The icons file should be located at: OS system-wide user-specific Unix /etc/lf/icons ~/.config/lf/icons Windows C:\ProgramData\lf\icons C:\Users\\AppData\Local\lf\icons -Selection file should be located at: +The selection file should be located at: Unix ~/.local/share/lf/files Windows C:\Users\\AppData\Local\lf\files -Marks file should be located at: +The marks file should be located at: Unix ~/.local/share/lf/marks Windows C:\Users\\AppData\Local\lf\marks -Tags file should be located at: +The tags file should be located at: Unix ~/.local/share/lf/tags Windows C:\Users\\AppData\Local\lf\tags -History file should be located at: +The history file should be located at: Unix ~/.local/share/lf/history Windows C:\Users\\AppData\Local\lf\history @@ -356,33 +340,26 @@ with their order of precedences and their default values: A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example - - COMMANDS - -This section shows information about builtin commands. Modal commands do -not take any arguments, but instead change the operation mode to read +This section shows information about built-in commands. Modal commands +do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings. - quit (default q) Quit lf and return to the shell. - up (default k and ), half-up (default ), page-up (default and ), scroll-up (default ), down (default j and ), half-down (default ), page-down (default and ), scroll-down (default ) Move/scroll the current file selection upwards/downwards by one/half a page/full page. - updir (default h and ) Change the current working directory to the parent directory. - open (default l and ) If the current file is a directory, then change the current directory to @@ -391,66 +368,57 @@ provided to call the default system opener asynchronously with the current file as the argument. A custom open command can be defined to override this default. - jump-next (default ]), jump-prev (default [) Change the current working directory to the next/previous jumplist item. - top (default gg and ), bottom (default G and ) Move the current file selection to the top/bottom of the directory. A -count can be specified to move to a specific line, for example use 3G to -move to the third line. - +count can be specified to move to a specific line, for example, use 3G +to move to the third line. high (default H), middle (default M), low (default L) Move the current file selection to the high/middle/low of the screen. - toggle Toggle the selection of the current file or files given as arguments. - invert (default v) Reverse the selection of all files in the current directory (i.e. toggle -all files). Selections in other directories are not effected by this +all files). Selections in other directories are not affected by this command. You can define a new command to select all files in the directory by combining invert with unselect (i.e. cmd select-all :unselect; invert), though this will also remove selections in other directories. - invert-below Reverse the selection (i.e. toggle) of all files at or after the current file in the current directory. To select a contiguous block of files, use this command on the first -file you want to select. Then, move down to the first file you do _not_ +file you want to select. Then, move down to the first file you do not want to select (the one after the end of the desired selection) and use this command again. This achieves an effect similar to the visual mode -in vim. +in Vim. This command is experimental and may be removed once a better replacement for the visual mode is implemented in lf. If you'd like to experiment with using this command, you should bind it to a key (e.g. V) for a better experience. - unselect (default u) Remove the selection of all files in all directories. - glob-select, glob-unselect Select/unselect files that match the given glob. - calcdirsize Calculate the total size for each of the selected directories. Option @@ -458,7 +426,6 @@ info should include size and option dircounts should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as -. - clearmaps Remove all keybindings associated with the map command. This command can @@ -466,186 +433,152 @@ be used in the config file to remove the default keybindings. For safety purposes, : is left mapped to the read command, and cmap keybindings are retained so that it is still possible to exit lf using :quit. - copy (default y) If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files. - cut (default d) If there are no selections, save the path of the current file to the cut buffer, otherwise, copy the paths of selected files. - paste (default p) -Copy/Move files in copy/cut buffer to the current working directory. A -custom paste command can be defined to override this default. - +Copy/Move files in the copy/cut buffer to the current working directory. +A custom paste command can be defined to override this default. clear (default c) Clear file paths in copy/cut buffer. - sync -Synchronize copied/cut files with server. This command is automatically -called when required. - +Synchronize copied/cut files with the server. This command is +automatically called when required. draw Draw the screen. This command is automatically called when required. - redraw (default ) Synchronize the terminal and redraw the screen. - load Load modified files and directories. This command is automatically called when required. - reload (default ) Flush the cache and reload all files and directories. - echo -Print given arguments to the message line at the bottom. - +Print the given arguments to the message line at the bottom. echomsg -Print given arguments to the message line at the bottom and also to the -log file. - +Print the given arguments to the message line at the bottom and also to +the log file. echoerr Print given arguments to the message line at the bottom as errorfmt and also to the log file. - cd Change the working directory to the given argument. - select Change the current file selection to the given argument. - delete (modal) Remove the current file or selected file(s). A custom delete command can be defined to override this default. - rename (modal) (default r) -Rename the current file using the builtin method. A custom rename +Rename the current file using the built-in method. A custom rename command can be defined to override this default. - source Read the configuration file given in the argument. - push Simulate key pushes given in the argument. - read (modal) (default :) Read a command to evaluate. - shell (modal) (default $) Read a shell command to execute. - shell-pipe (modal) (default %) Read a shell command to execute piping its standard I/O to the bottom statline. - shell-wait (modal) (default !) Read a shell command to execute and wait for a key press in the end. - shell-async (modal) (default &) Read a shell command to execute asynchronously without standard I/O. - find (modal) (default f), find-back (modal) (default F), find-next (default ;), find-prev (default ,) Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match. - search (default /), search-back (default ?), search-next (default n), search-prev (default N) Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match. - filter (modal), setfilter Command filter reads a pattern to filter out and only view files matching the pattern. Command setfilter does the same but uses an argument to set the filter immediately. You can supply an argument to -filter, in order to use that as the starting prompt. - +filter to use as the starting prompt. mark-save (modal) (default m) Save the current directory as a bookmark assigned to the given key. - mark-load (modal) (default ') Change the current directory to the bookmark assigned to the given key. A special bookmark ' holds the previous directory after a mark-load, cd, or select command. - mark-remove (modal) (default ") Remove a bookmark assigned to the given key. - tag -Tag a file with * or a single width character given in the argument. You -can define a new tag clearing command by combining tag with tag-toggle +Tag a file with * or a single-width character given in the argument. You +can define a new tag-clearing command by combining tag with tag-toggle (i.e. cmd tag-clear :tag; tag-toggle). - tag-toggle (default t) Tag a file with * or a single width character given in the argument if the file is untagged, otherwise remove the tag. - - COMMAND LINE COMMANDS - The prompt character specifies which of the several command-line modes you are in. For example, the read command takes you to the : mode. @@ -654,151 +587,124 @@ keys !, $, %, or & takes you to the corresponding mode. You can go back with cmd-delete-back ( by default). The command line commands should be mostly compatible with readline -keybindings. A character refers to a unicode code point, a word consists +keybindings. A character refers to a Unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters. - cmd-escape (default ) Quit command line mode and return to normal mode. - cmd-complete (default ) Autocomplete the current word. - cmd-menu-complete, cmd-menu-complete-back -Autocomplete the current word with menu selection. You need to assign -keys to these commands (e.g. +Autocomplete the current word with the 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. - +You can use the assigned keys to display the menu and then cycle through +completion options. cmd-menu-accept Accept the currently selected match in menu completion and close the menu. - cmd-enter (default and ) Execute the current line. - cmd-interrupt (default ) Interrupt the current shell-pipe command and return to the normal mode. - cmd-history-next (default and ), cmd-history-prev (default and ) -Go to next/previous item in the history. - +Go to the next/previous item in the history. cmd-left (default and ), cmd-right (default and ) Move the cursor to the left/right. - cmd-home (default and ), cmd-end (default and ) -Move the cursor to the beginning/end of line. - +Move the cursor to the beginning/end of the line. cmd-delete (default and ) Delete the next character. - cmd-delete-back (default and ) Delete the previous character. When at the beginning of a prompt, returns either to normal mode or to : mode. - cmd-delete-home (default ), cmd-delete-end (default ) -Delete everything up to the beginning/end of line. - +Delete everything up to the beginning/end of the line. cmd-delete-unix-word (default ) Delete the previous unix word. - cmd-yank (default ) Paste the buffer content containing the last deleted item. - cmd-transpose (default ), cmd-transpose-word (default ) -Transpose the positions of last two characters/words. - +Transpose the positions of the last two characters/words. cmd-word (default ), cmd-word-back (default ) -Move the cursor by one word in forward/backward direction. - +Move the cursor by one word in the forward/backward direction. cmd-delete-word (default ) -Delete the next word in forward direction. - +Delete the next word in the forward direction. cmd-delete-word-back (default and ) -Delete the previous word in backward direction. - +Delete the previous word in the backward direction. cmd-capitalize-word (default ), cmd-uppercase-word (default ), cmd-lowercase-word (default ) Capitalize/uppercase/lowercase the current word and jump to the next word. - - OPTIONS - This section shows information about options to customize the behavior. Character : is used as the separator for list options []int and []string. - anchorfind (bool) (default true) -When this option is enabled, find command starts matching patterns from -the beginning of file names, otherwise, it can match at an arbitrary -position. - +When this option is enabled, the find command starts matching patterns +from the beginning of file names, otherwise, it can match at an +arbitrary position. autoquit (bool) (default false) -Automatically quit server when there are no clients left connected. - +Automatically quit the server when there are no clients left connected. borderfmt (string) (default \033[0m) Format string of the box drawing characters enabled by the drawbox option. - cleaner (string) (default ``) (not called if empty) Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the -previously selected file had its preview cache disabled. The following +previously selected file has its preview cache disabled. The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively. Preview cleaning is disabled when the value of this option is left empty. - cursoractivefmt (string) (default \033[7m), cursorparentfmt string (default \033[7m), cursorpreviewfmt string (default \033[4m) Format strings for highlighting the cursor. cursoractivefmt applies in @@ -819,12 +725,10 @@ format string for fmt.Sprintf. Such a string should end with the terminal reset sequence. For example, \033[4m%s\033[0m has the same effect as \033[4m. - dircache (bool) (default true) Cache directory contents. - dircounts (bool) (default false) When this option is enabled, directory sizes show the number of items @@ -836,36 +740,31 @@ This option only has an effect when info has a size field and the pane is wide enough to show the information. 999 items are counted per directory at most, and bigger directories are shown as 999+. - dirfirst (bool) (default true) Show directories first above regular files. - dironly (bool) (default false) Show only directories. - dirpreviews (bool) (default false) If enabled, directories will also be passed to the previewer script. This allows custom previews for directories. - drawbox (bool) (default false) Draw boxes around panes with box drawing characters. - dupfilefmt (string) (default %f.~%n~) Format string of file name when creating duplicate files. With the default format, copying a file abc.txt to the same directory will result in a duplicate file called abc.txt.~1~. Special expansions are provided, -%f as the file name, %b for basename (file name without extension), %e -as the extension (including the dot) and %n as the number of duplicates. - +%f as the file name, %b for the basename (file name without extension), +%e as the extension (including the dot) and %n as the number of +duplicates. errorfmt (string) (default \033[7;31;47m) @@ -876,33 +775,28 @@ format string for fmt.Sprintf. Such a string should end with the terminal reset sequence. For example, \033[4m%s\033[0m has the same effect as \033[4m. - filesep (string) (default \n) File separator used in environment variables fs and fx. - findlen (int) (default 1) Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left. - globsearch (bool) (default false) When this option is enabled, search command patterns are considered as -globs, otherwise they are literals. With globbing, * matches any +globs, otherwise, they are literals. With globbing, * matches any sequence, ? matches any character, and [...] or [^...] matches character sets or ranges. Otherwise, these characters are interpreted as they are. - hidden (bool) (default false) Show hidden files. On Unix systems, hidden files are determined by the value of hiddenfiles. On Windows, only files with hidden attributes are considered hidden files. - hiddenfiles ([]string) (default .*) List of hidden file glob patterns. Patterns can be given as relative or @@ -912,84 +806,71 @@ match character sets or ranges. In addition, if a pattern starts with !, then its matches are excluded from hidden files. To add multiple patterns, use : as a separator. Example: .*:lost+found:*.bak - history (bool) (default true) Save command history. - icons (bool) (default false) Show icons before each item in the list. - ifs (string) (default ``) Sets IFS variable in shell commands. It works by adding the assignment to the beginning of the command string as IFS=...; .... The reason is that IFS variable is not inherited by the shell for security reasons. -This method assumes a POSIX shell syntax and so it can fail for -non-POSIX shells. This option has no effect when the value is left -empty. This option does not have any effect on Windows. - +This method assumes a POSIX shell syntax so it can fail for non-POSIX +shells. This option has no effect when the value is left empty. This +option does not have any effect on Windows. ignorecase (bool) (default true) Ignore case in sorting and search patterns. - ignoredia (bool) (default true) Ignore diacritics in sorting and search patterns. - incsearch (bool) (default false) Jump to the first match after each keystroke during searching. - incfilter (bool) (default false) Apply filter pattern after each keystroke during filtering. - info ([]string) (default ``) -List of information shown for directory items at the right side of pane. -Currently supported information types are size, time, atime, and ctime. -Information is only shown when the pane width is more than twice the -width of information. - +A list of information that is shown for directory items at the right +side of the pane. Currently supported information types are size, time, +atime, and ctime. Information is only shown when the pane width is more +than twice the width of information. infotimefmtnew (string) (default Jan _2 15:04) Format string of the file time shown in the info column when it matches this year. - infotimefmtold (string) (default Jan _2 2006) Format string of the file time shown in the info column when it doesn't match this year. - mouse (bool) (default false) Send mouse events as input. - number (bool) (default false) -Show the position number for directory items at the left side of pane. -When relativenumber option is enabled, only the current line shows the -absolute position and relative positions are shown for the rest. - +Show the position number for directory items on the left side of the +pane. When the relativenumber option is enabled, only the current line +shows the absolute position and relative positions are shown for the +rest. numberfmt (string) (default \033[33m) Format string of the position number for each line. - period (int) (default 0) Set the interval in seconds for periodic checks of directory updates. @@ -999,24 +880,21 @@ can be useful when there is an external process changing the displayed directory and you are not doing anything in lf. Periodic checks are disabled when the value of this option is set to zero. - preserve ([]string) (default mode) List of attributes that are preserved when copying files. Currently supported attributes are mode (i.a. access mode) and timestamps (i.e. -modification time and access time). Note, preserving other attribute -like ownership of change/birth timestamp is desirable, but not portably -supported in Go. - +modification time and access time). Note that preserving other +attributes like ownership of change/birth timestamp is desirable, but +not portably supported in Go. preview (bool) (default true) -Show previews of files and directories at the right most pane. If the -file has more lines than the preview pane, rest of the lines are not +Show previews of files and directories at the rightmost pane. If the +file has more lines than the preview pane, the rest of the lines are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as binary. - previewer (string) (default ``) (not filtered if empty) Set the path of a previewer file to filter the content of regular files @@ -1030,39 +908,34 @@ 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. - +are provided, %u as the user name, %h as the hostname, %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. The home folder is shown as ~ in the working directory +expansion. Directory names are automatically shortened to a single +character starting from the leftmost parent when the prompt does not fit +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. - +the number of panes in the UI. When the preview option is enabled, the +rightmost number is used for the width of the preview pane. relativenumber (bool) (default false) Show the position number relative to the current line. When number is -enabled, current line shows the absolute position, otherwise nothing is -shown. - +enabled, the current line shows the absolute position, otherwise nothing +is shown. reverse (bool) (default false) Reverse the direction of sort. - ruler ([]string) (default acc:progress:selection:filter:ind) This option is deprecated in favor of using the rulerfmt option (see @@ -1078,11 +951,10 @@ the number of files in the current directory. df shows the amount of free disk space remaining. Names starting with lf_ show the value of environment variables exported by lf. This is useful for displaying the current settings (e.g. lf_selmode displays the current setting for the -selmode option). User defined options starting with lf_user_ are also +selmode option). User-defined options starting with lf_user_ are also supported, so it is possible to display information set from external sources. - rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t) Format string of the ruler shown in the bottom right corner. Special @@ -1094,12 +966,11 @@ shown in the current directory, %h as the number of files hidden in the current directory, and %d as the amount of free disk space remaining. Additional expansions are provided for environment variables exported by lf, in the form %{lf_} (e.g. %{lf_selmode}). This is useful for -displaying the current settings. Expansions are also provided for user -defined options, in the form %{lf_user_} (e.g. %{lf_user_foo}). -The | character splits the format string into sections. Any section -containing a failed expansion (result is a blank string) is discarded -and not shown. - +displaying the current settings. Expansions are also provided for +user-defined options, in the form %{lf_user_} (e.g. +%{lf_user_foo}). The | character splits the format string into sections. +Any section containing a failed expansion (result is a blank string) is +discarded and not shown. selmode (string) (default all) @@ -1107,56 +978,47 @@ 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. - +Minimum number of offset lines shown at all times at the top and bottom +of the screen when scrolling. The current line is kept in the middle +when this option is set to a large value that is bigger than the half of +number of lines. A smaller offset can be used when the current file is +close to the beginning or end of the list to show the maximum number of +items. shell (string) (default sh for Unix and cmd for Windows) Shell executable to use for shell commands. Shell commands are executed as shell shellopts shellflag command -- arguments. - shellflag (string) (default -c for Unix and /c for Windows) Command line flag used to pass shell commands. - shellopts ([]string) (default ``) List of shell options to pass to the shell executable. - sixel (bool) (default false) Render sixel images in preview. - smartcase (bool) (default true) Override ignorecase option when the pattern contains an uppercase character. This option has no effect when ignorecase is disabled. - smartdia (bool) (default false) Override ignoredia option when the pattern contains a character with diacritic. This option has no effect when ignoredia is disabled. - sortby (string) (default natural) Sort type for directories. Currently supported sort types are natural, name, size, time, ctime, atime, and ext. - statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l) Format string of the file info shown in the bottom left corner. Special @@ -1168,13 +1030,11 @@ character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. - tabstop (int) (default 8) Number of space characters to show for horizontal tabulation (U+0009) character. - tagfmt (string) (default \033[31m) Format string of the tags. @@ -1184,7 +1044,6 @@ format string for fmt.Sprintf. Such a string should end with the terminal reset sequence. For example, \033[4m%s\033[0m has the same effect as \033[4m. - tempmarks (string) (default ``) Marks to be considered temporary (e.g. abc refers to marks a, b, and c). @@ -1192,28 +1051,25 @@ These marks are not synced to other clients and they are not saved in the bookmarks file. Note that the special bookmark ` is always treated as temporary and it does not need to be specified. - timefmt (string) (default Mon Jan _2 15:04:05 2006) Format string of the file modification time shown in the bottom line. - truncatechar (string) (default ~) -Truncate character shown at the end when the file name does not fit to -the pane. - +The truncate character that is shown at the end when the file name does +not fit into the pane. truncatepct (int) (default 100) When a filename is too long to be shown completely, the available space -is partitioned in two pieces. truncatepct defines a fraction (in percent -between 0 and 100) for the size of the first piece, which will show the -beginning of the filename. The second piece will show the end of the -filename and will use the rest of the available space. Both pieces are -separated by the truncation character (truncatechar). A value of 100 -will only show the beginning of the filename, while a value of 0 will -only show the end of the filename, e.g.: +is partitioned into two pieces. truncatepct defines a fraction (in +percent between 0 and 100) for the size of the first piece, which will +show the beginning of the filename. The second piece will show the end +of the filename and will use the rest of the available space. Both +pieces are separated by the truncation character (truncatechar). A value +of 100 will only show the beginning of the filename, while a value of 0 +will only show the end of the filename, e.g.: - set truncatepct 100 -> very-long-filename-tr~ (default) @@ -1221,72 +1077,58 @@ only show the end of the filename, e.g.: - set truncatepct 0 -> ~ng-filename-truncated - waitmsg (string) (default Press any key to continue) String shown after commands of shell-wait type. - wrapscan (bool) (default true) Searching can wrap around the file list. - wrapscroll (bool) (default false) Scrolling can wrap around the file list. - user_{option} (string) (default none) -Any option that is prefixed with user_ is a user defined option and can -be set to any string. Inside a user defined command the value will be +Any option that is prefixed with user_ is a user-defined option and can +be set to any string. Inside a user-defined command, the value will be provided in the lf_user_{option} environment variable. These options are not used by lf and are not persisted. - - ENVIRONMENT VARIABLES - The following variables are exported for shell commands: These are -referred with a $ prefix on POSIX shells (e.g. $f), between % characters -on Windows cmd (e.g. %f%), and with a $env: prefix on Windows powershell -(e.g. $env:f). - +referred to with a $ prefix on POSIX shells (e.g. $f), between % +characters on Windows cmd (e.g. %f%), and with a $env: prefix on Windows +PowerShell (e.g. $env:f). f Current file selection as a full path. - fs Selected file(s) separated with the value of filesep option as full path(s). - fx Selected file(s) (i.e. fs) if there are any selected files, otherwise current file selection (i.e. f). - id Id of the running client. - PWD Present working directory. - OLDPWD Initial working directory. - LF_LEVEL The value of this variable is set to the current nesting level when you @@ -1296,141 +1138,114 @@ inside lf. For example, with POSIX shells, you can use [ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) " in your shell configuration file (e.g. ~/.bashrc). - OPENER If this variable is set in the environment, use the same value. Otherwise, this is set to start in Windows, open in MacOS, xdg-open in others. - EDITOR If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to vi on Unix, notepad in Windows. - PAGER If this variable is set in the environment, use the same value. Otherwise, this is set to less on Unix, more in Windows. - SHELL If this variable is set in the environment, use the same value. Otherwise, this is set to sh on Unix, cmd in Windows. - lf Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string lf. - lf_{option} Value of the {option}. - lf_user_{option} Value of the user_{option}. - lf_width, lf_height Width/Height of the terminal. - lf_count Value of the count associated with the current command. - - SPECIAL COMMANDS - This section shows information about special shell commands. - open This shell command can be defined to override the default open command when the current file is not a directory. - paste This shell command can be defined to override the default paste command. - rename This shell command can be defined to override the default rename command. - delete This shell command can be defined to override the default delete command. - pre-cd This shell command can be defined to be executed before changing a directory. - on-cd This shell command can be defined to be executed after changing a directory. - on-select This shell command can be defined to be executed after the selection changes. - on-redraw This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized. - on-quit -This shell command can be defined to be executed before quit. - - +This shell command can be defined to be executed before quitting. 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-pipe shell command running with the UI + ! shell-wait shell command waiting for a 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. - - +file for reading shell commands. The difference is that prefixes are not +necessary in the command line. Instead, different modes are provided to +read corresponding commands. These modes are mapped to the prefix keys +above by default. SYNTAX - Characters from # to newline are comments and ignored: # comments start with `#` @@ -1438,7 +1253,7 @@ Characters from # to newline are comments and ignored: There are five special commands (set, setlocal, map, cmap, and cmd) for configuration. -Command set is used to set an option which can be boolean, integer, or +Command set is used to set an option which can be a boolean, integer, or string: set hidden # boolean enable @@ -1452,7 +1267,7 @@ string: set sortby "time" # string value with double quotes (backslash escapes) Command setlocal is used to set a local option for a directory which can -be boolean or string. Currently supported local options are dirfirst, +be a boolean or string. Currently supported local options are dirfirst, dironly, hidden, info, reverse, and sortby. Adding a trailing path separator (i.e. / for Unix and \ for Windows) sets the option for the given directory along with its subdirectories: @@ -1468,7 +1283,7 @@ given directory along with its subdirectories: setlocal /foo/bar hidden # for only '/foo/bar' directory setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') -Command 'map' is used to bind a key to a command which can be builtin +Command 'map' is used to bind a key to a command which can be a builtin command, custom command, or shell command: map gh cd ~ # builtin command @@ -1512,11 +1327,8 @@ proper prefix. set info time }} - - KEY MAPPINGS - Regular keys are assigned to a command with the usual syntax: map a down @@ -1539,7 +1351,7 @@ Function keys are prefixed with f character: map down -Keys combined with the control key are prefixed with c character: +Keys combined with the control key are prefixed with a c character: map down @@ -1553,7 +1365,8 @@ terminals, you can use the corresponding byte for the mapping: Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed. lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms). On these -terminals, keys combined with the alt key are prefixed with a character: +terminals, keys combined with the alt key are prefixed with an a +character: map down @@ -1568,7 +1381,7 @@ backspace key instead). The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the unknown mapping error. -Mouse buttons are prefixed with m character: +Mouse buttons are prefixed with an m character: map down # primary map down # secondary @@ -1579,22 +1392,19 @@ Mouse buttons are prefixed with m character: map down map down -Mouse wheel events are also prefixed with m character: +Mouse wheel events are also prefixed with an m character: map down map down map down map down - - PUSH MAPPINGS - The usual way to map a key sequence is to assign it to a named or -unnamed command. While this provides a clean way to remap builtin keys -as well as other commands, it can be limiting at times. For this reason -push command is provided by lf. This command is used to simulate key +unnamed command. While this provides a clean way to remap built-in keys +as well as other commands, it can be limiting at times. For this reason, +the 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. @@ -1608,21 +1418,18 @@ 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 +One thing to be careful of is that since the push command works with +keys instead of commands it is possible to accidentally create recursive bindings: map j push 2j These types of bindings create a deadlock when executed. - - SHELL COMMANDS - Regular shell commands are the most basic command type that is useful -for many purposes. For example, we can write a shell command to move +for many purposes. For example, we can write a shell command to move the selected file(s) to trash. A first attempt to write such a command may look like this: @@ -1635,7 +1442,7 @@ look like this: fi }} -We check $fs to see if there are any selected files. Otherwise we just +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: @@ -1652,35 +1459,32 @@ move it outside of the command so it would only run once at startup: cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }} -Since these are one liners, we can drop {{ and }}: +Since these are one-liners, we can drop {{ and }}: $mkdir -p ~/.trash cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.trash -Finally note that we set IFS variable manually in these commands. -Instead we could use the ifs option to set it for all shell commands +Finally, note that we set the IFS variable manually in these commands. +Instead, we could use the ifs option to set it for all shell commands (i.e. set ifs "\n"). This can be especially useful for interactive use (e.g. $rm $f or $rm $fs would simply work). This option is not set by default as it can behave unexpectedly for new users. However, use of this option is highly recommended and it is assumed in the rest of the documentation. - - PIPING SHELL COMMANDS - Regular shell commands have some limitations in some cases. When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. Also, even when there is no output or error, -the ui still needs to be paused while the command is running. This can +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 +Instead of pausing the UI, piping shell commands connect stdin, stdout, +and stderr of the command to the statline at 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. @@ -1698,32 +1502,23 @@ this: Note that input is line buffered and output and error are byte buffered. - - WAITING SHELL COMMANDS - Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. These can be -useful to see the output of a program before the ui is resumed. Waiting +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. - - +finish. Stdin, stdout, and stderr of the command are neither connected +to the terminal nor the UI. REMOTE COMMANDS - One of the more advanced features in lf is remote commands. All clients connect to a server on startup. It is possible to send commands to all or any of the connected clients over the common server. This is used @@ -1745,7 +1540,7 @@ 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 +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' @@ -1753,7 +1548,7 @@ send a command to a single client: All clients have a unique id number but you may not be aware of the id number when you are writing a command. For this purpose, an $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 +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: @@ -1762,7 +1557,7 @@ client by calling the following in a shell command: 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: +UI with respect to the terminal width as follows: cmd recol %{{ if [ $lf_width -le 80 ]; then @@ -1808,19 +1603,16 @@ closing client connections first: lf -remote 'quit' lf -remote 'quit!' -Lastly, there is a conn command to connect the server as a client. This +Lastly, there is a conn command to connect the server to a client. This should not be needed for users. - - FILE OPERATIONS - -lf uses its own builtin copy and move operations by default. These are +lf uses its own built-in 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 +with the --backup=numbered option in GNU cp is added to the new files or directories. Only file modes and (some) timestamps can be preserved (see preserve option), all other attributes are ignored including ownership, context, and xattr. Special files such as character and block devices, @@ -1831,15 +1623,15 @@ 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 currently selected file or 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 +the built-in implementation. You can use the following example as a starting point: cmd paste %{{ @@ -1865,19 +1657,16 @@ 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. - - +a prompt is provided in the example configuration file. SEARCHING FILES - There are two mechanisms implemented in lf to search a file in the current directory. Searching is the traditional method to move the selection to a file matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes. -Searching mechanism is implemented with commands search (default /), +The 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 @@ -1892,32 +1681,30 @@ mapping: cmap :cmd-enter; open -Finding mechanism is implemented with commands find (default f), +The 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 +zero, then the keys are read until there is only a single match. The +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 from being wrapped around at the end of the +file list. You can disable ignorecase option to match cases in the +pattern and the filename. This option is already automatically +overridden if the pattern contains upper-case characters. You can +disable smartcase option to disable this behavior. Two similar options +ignoredia and smartdia are provided to control matching diacritics in +Latin letters. OPENING FILES - -You can define a an open command (default l and ) to configure -file opening. This command is only called when the current file is not a -directory, otherwise the directory is entered instead. You can define it -just as you would define any other command: +You can define 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 @@ -1938,11 +1725,11 @@ command: You may want to use setsid before your opener command to have persistent processes that continue to run after lf quits. -Regular shell commands (i.e. $) drop to terminal which results in a -flicker for commands that finishes immediately (e.g. xdg-open in the -above example). If you want to use asynchronous shell commands (i.e. &) -but also want to use the terminal when necessary (e.g. vi in the above -exxample), you can use a remote command: +Regular shell commands (i.e. $) drop to the terminal which results in a +flicker for commands that finish immediately (e.g. xdg-open in the above +example). If you want to use asynchronous shell commands (i.e. &) but +also want to use the terminal when necessary (e.g. vi in the above +example), you can use a remote command: cmd open &{{ case $(file --mime-type -Lb $f) in @@ -1951,10 +1738,10 @@ exxample), you can use a remote command: esac }} -Note, asynchronous shell commands run in their own process group by +Note that asynchronous shell commands run in their own process group by default so they do not require the manual use of setsid. -Following command is provided by default: +The following command is provided by default: cmd open &$OPENER $f @@ -1962,23 +1749,20 @@ You may also use any other existing file openers as you like. Possible options are libfile-mimeinfo-perl (executable name is mimeopen), rifle (ranger's default file opener), or mimeo to name a few. - - PREVIEWING FILES - lf previews files on the preview pane by printing the file until the end -or the preview pane is filled. This output can be enhanced by providing -a custom preview script for filtering. This can be used to highlight -source codes, list contents of archive files or view pdf or image files -to name a few. For coloring lf recognizes ansi escape codes. +or until 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: +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. The output of +the execution is printed in the preview pane. You may also want to use +the same script in your pager mapping as well: set previewer ~/.config/lf/pv.sh map i $~/.config/lf/pv.sh $f | less -R @@ -2010,28 +1794,25 @@ Extensions can then be used to match cleanly within a conditional: Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 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: +important that the application processes the file on the fly rather than +first reading it to the memory and then doing the processing afterwards. +This is especially relevant for big files. lf automatically closes the +previewer script output pipe with a SIGPIPE when enough lines are read. +When everything else fails, you can make use of the height argument to +only feed the first portion of the file to a program for preview. Note +that some programs may not respond well to SIGPIPE to exit with a +non-zero return code and avoid caching. You may add a trailing || true +command to avoid such errors: 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. - - +documentation for more information. CHANGING DIRECTORY - lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first @@ -2059,15 +1840,15 @@ would 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 +/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 the directory but not on startup. +You can add an extra call to make it run on startup as well: cmd on-cd &{{ ... }} on-cd @@ -2078,13 +1859,10 @@ appropriate as $ and ! causes flickers and pauses respectively. There is also a pre-cd command, that works like on-cd, but is run before the directory is actually changed. - - COLORS - lf tries to automatically adapt its colors to the environment. It starts -with a default colorscheme and updates colors using values of existing +with a default color scheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order: @@ -2098,10 +1876,11 @@ 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. +though one should expect the same behavior for common cases. The colors +file (refer to the CONFIGURATION section) is provided for easier +configuration without environment variables. This file should consist of +whitespace-separated pairs with a # character to start comments until +the end of the 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 @@ -2111,15 +1890,15 @@ 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 +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. +this second method with the first method for the 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 +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 @@ -2191,16 +1970,16 @@ checked in the configuration and the first one to match is used: 7. *.d 8. fi -Note that glob-like patterns do not actually perform glob matching due -to performance reasons. +Note that glob-like patterns do not perform glob matching for +performance reasons. For example, you can set a variable as follows: export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:" Having all entries on a single line can make it hard to read. You may -instead divide it to multiple lines in between double quotes by escaping -newlines with backslashes as follows: +instead divide it into multiple lines in between double quotes by +escaping newlines with backslashes as follows: export LF_COLORS="\ ~/Documents=01;31:\ @@ -2220,24 +1999,22 @@ newlines with backslashes as follows: " 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 +might be undesirable. You may instead use the colors file (refer to the +CONFIGURATION section) for configuration. A sample colors file can be +found at https://github.com/gokcehan/lf/blob/master/etc/colors.example +You may also see the wiki page for ANSI escape codes https://en.wikipedia.org/wiki/ANSI_escape_code - - ICONS - Icons are configured using LF_ICONS environment variable or an icons -file. The variable uses the same syntax as LS_COLORS/LF_COLORS. Instead -of colors, you should put a single characters as values of entries. -Icons file should consist of whitespace separated pairs with # character -to start comments until the end of line. Do not forget to enable icons -option to see the icons. Default values are as follows given with their -matching order in lf: +file (refer to the CONFIGURATION section). The variable uses the same +syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a +single characters as values of entries. The icons file (refer to the +CONFIGURATION section) should consist of whitespace-separated pairs with +a # character to start comments until the end of the line. Do not forget +to add set icons true to your lfrc to see the icons. Default values are +as follows given with their matching order in lf: ln l or l diff --git a/eval.go b/eval.go index 47c8eebf..a3daef4c 100644 --- a/eval.go +++ b/eval.go @@ -68,6 +68,27 @@ func (e *setExpr) eval(app *app, args []string) { gOpts.cursorparentfmt = e.val case "cursorpreviewfmt": gOpts.cursorpreviewfmt = e.val + case "hidecursorinactive": + if e.val == "" || e.val == "true" { + gOpts.hidecursorinactive = true + } else if e.val == "false" { + gOpts.hidecursorinactive = false + } else { + app.ui.echoerr("hidecursorinactive: value should be empty, 'true', or 'false'") + return + } + case "nohidecursorinactive": + if e.val != "" { + app.ui.echoerrf("nohidecursorinactive: unexpected value: %s", e.val) + return + } + gOpts.hidecursorinactive = false + case "hidecursorinactive!": + if e.val != "" { + app.ui.echoerrf("hidecursorinactive!: unexpected value: %s", e.val) + return + } + gOpts.hidecursorinactive = !gOpts.hidecursorinactive case "dircache": if e.val == "" || e.val == "true" { gOpts.dircache = true diff --git a/lf.1 b/lf.1 index 826d604a..fda9d506 100644 --- a/lf.1 +++ b/lf.1 @@ -1,37 +1,36 @@ -.\" Automatically generated by Pandoc 2.5 +.\" Automatically generated by Pandoc 2.11.4 .\" -.TH "LF" "1" "2023\-11\-06" "r31\-17\-g31402e6" "DOCUMENTATION" +.TH "LF" "1" "2023-12-19" "r27-218-g39ad76d" "DOCUMENTATION" .hy .SH NAME .PP -lf \- terminal file manager +lf - terminal file manager .SH SYNOPSIS .PP -\f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R] -\f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]] -[\f[B]\-doc\f[R]] [\f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]] -[\f[B]\-log path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]] -[\f[B]\-print\-last\-dir\f[R]] [\f[B]\-print\-selection\f[R]] -[\f[B]\-remote\f[R] \f[I]command\f[R]] [\f[B]\-selection\-path\f[R] -\f[I]path\f[R]] [\f[B]\-server\f[R]] [\f[B]\-single\f[R]] -[\f[B]\-version\f[R]] [\f[B]\-help\f[R]] -[\f[I]cd\-or\-select\-path\f[R]] +\f[B]lf\f[R] [\f[B]-command\f[R] \f[I]command\f[R]] [\f[B]-config\f[R] +\f[I]path\f[R]] [\f[B]-cpuprofile\f[R] \f[I]path\f[R]] [\f[B]-doc\f[R]] +[\f[B]-last-dir-path\f[R] \f[I]path\f[R]] [\f[B]-log path\f[R]] +[\f[B]-memprofile\f[R] \f[I]path\f[R]] [\f[B]-print-last-dir\f[R]] +[\f[B]-print-selection\f[R]] [\f[B]-remote\f[R] \f[I]command\f[R]] +[\f[B]-selection-path\f[R] \f[I]path\f[R]] [\f[B]-server\f[R]] +[\f[B]-single\f[R]] [\f[B]-version\f[R]] [\f[B]-help\f[R]] +[\f[I]cd-or-select-path\f[R]] .SH DESCRIPTION .PP lf is a terminal file manager. .PP -Source code can be found in the repository at -https://github.com/gokcehan/lf (https://github.com/gokcehan/lf) +The source code can be found in the repository at + .PP -This documentation can either be read from terminal using -\f[C]lf \-doc\f[R] or online at -https://github.com/gokcehan/lf/blob/master/doc.md (https://github.com/gokcehan/lf/blob/master/doc.md) -You can also use \f[C]doc\f[R] command (default \f[C]\f[R]) inside -lf to view the documentation in a pager. +This documentation can either be read from the terminal using +\f[C]lf -doc\f[R] or online at + You can also use the +\f[C]doc\f[R] command (default \f[C]\f[R]) inside lf to view the +documentation in a pager. A man page with the same content is also available in the repository at -https://github.com/gokcehan/lf/blob/master/lf.1 (https://github.com/gokcehan/lf/blob/master/lf.1) + .PP -You can run \f[C]lf \-help\f[R] to see descriptions of command line +You can run \f[C]lf -help\f[R] to see descriptions of command line options. .SH QUICK REFERENCE .PP @@ -41,17 +40,17 @@ The following commands are provided by lf: \f[C] quit (default \[aq]q\[aq]) up (default \[aq]k\[aq] and \[aq]\[aq]) -half\-up (default \[aq]\[aq]) -page\-up (default \[aq]\[aq] and \[aq]\[aq]) -scroll\-up (default \[aq]\[aq]) +half-up (default \[aq]\[aq]) +page-up (default \[aq]\[aq] and \[aq]\[aq]) +scroll-up (default \[aq]\[aq]) down (default \[aq]j\[aq] and \[aq]\[aq]) -half\-down (default \[aq]\[aq]) -page\-down (default \[aq]\[aq] and \[aq]\[aq]) -scroll\-down (default \[aq]\[aq]) +half-down (default \[aq]\[aq]) +page-down (default \[aq]\[aq] and \[aq]\[aq]) +scroll-down (default \[aq]\[aq]) updir (default \[aq]h\[aq] and \[aq]\[aq]) open (default \[aq]l\[aq] and \[aq]\[aq]) -jump\-next (default \[aq]]\[aq]) -jump\-prev (default \[aq][\[aq]) +jump-next (default \[aq]]\[aq]) +jump-prev (default \[aq][\[aq]) top (default \[aq]gg\[aq] and \[aq]\[aq]) bottom (default \[aq]G\[aq] and \[aq]\[aq]) high (default \[aq]H\[aq]) @@ -59,10 +58,10 @@ middle (default \[aq]M\[aq]) low (default \[aq]L\[aq]) toggle invert (default \[aq]v\[aq]) -invert\-below +invert-below unselect (default \[aq]u\[aq]) -glob\-select -glob\-unselect +glob-select +glob-unselect calcdirsize clearmaps copy (default \[aq]y\[aq]) @@ -71,9 +70,9 @@ paste (default \[aq]p\[aq]) clear (default \[aq]c\[aq]) sync draw -redraw (default \[aq]\[aq]) +redraw (default \[aq]\[aq]) load -reload (default \[aq]\[aq]) +reload (default \[aq]\[aq]) echo echomsg echoerr @@ -85,24 +84,24 @@ source push read (modal) (default \[aq]:\[aq]) shell (modal) (default \[aq]$\[aq]) -shell\-pipe (modal) (default \[aq]%\[aq]) -shell\-wait (modal) (default \[aq]!\[aq]) -shell\-async (modal) (default \[aq]&\[aq]) +shell-pipe (modal) (default \[aq]%\[aq]) +shell-wait (modal) (default \[aq]!\[aq]) +shell-async (modal) (default \[aq]&\[aq]) find (modal) (default \[aq]f\[aq]) -find\-back (modal) (default \[aq]F\[aq]) -find\-next (default \[aq];\[aq]) -find\-prev (default \[aq],\[aq]) +find-back (modal) (default \[aq]F\[aq]) +find-next (default \[aq];\[aq]) +find-prev (default \[aq],\[aq]) search (modal) (default \[aq]/\[aq]) -search\-back (modal) (default \[aq]?\[aq]) -search\-next (default \[aq]n\[aq]) -search\-prev (default \[aq]N\[aq]) +search-back (modal) (default \[aq]?\[aq]) +search-next (default \[aq]n\[aq]) +search-prev (default \[aq]N\[aq]) filter (modal) setfilter -mark\-save (modal) (default \[aq]m\[aq]) -mark\-load (modal) (default \[dq]\[aq]\[dq]) -mark\-remove (modal) (default \[aq]\[dq]\[aq]) +mark-save (modal) (default \[aq]m\[aq]) +mark-load (modal) (default \[dq]\[aq]\[dq]) +mark-remove (modal) (default \[aq]\[dq]\[aq]) tag -tag\-toggle (default \[aq]t\[aq]) +tag-toggle (default \[aq]t\[aq]) \f[R] .fi .PP @@ -110,34 +109,34 @@ The following command line commands are provided by lf: .IP .nf \f[C] -cmd\-escape (default \[aq]\[aq]) -cmd\-complete (default \[aq]\[aq]) -cmd\-menu\-complete -cmd\-menu\-complete\-back -cmd\-menu\-accept -cmd\-enter (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-interrupt (default \[aq]\[aq]) -cmd\-history\-next (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-history\-prev (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-left (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-right (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-home (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-end (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-delete (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-delete\-back (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-delete\-home (default \[aq]\[aq]) -cmd\-delete\-end (default \[aq]\[aq]) -cmd\-delete\-unix\-word (default \[aq]\[aq]) -cmd\-yank (default \[aq]\[aq]) -cmd\-transpose (default \[aq]\[aq]) -cmd\-transpose\-word (default \[aq]\[aq]) -cmd\-word (default \[aq]\[aq]) -cmd\-word\-back (default \[aq]\[aq]) -cmd\-delete\-word (default \[aq]\[aq]) -cmd\-delete\-word\-back (default \[aq]\[aq] and \[aq]\[aq]) -cmd\-capitalize\-word (default \[aq]\[aq]) -cmd\-uppercase\-word (default \[aq]\[aq]) -cmd\-lowercase\-word (default \[aq]\[aq]) +cmd-escape (default \[aq]\[aq]) +cmd-complete (default \[aq]\[aq]) +cmd-menu-complete +cmd-menu-complete-back +cmd-menu-accept +cmd-enter (default \[aq]\[aq] and \[aq]\[aq]) +cmd-interrupt (default \[aq]\[aq]) +cmd-history-next (default \[aq]\[aq] and \[aq]\[aq]) +cmd-history-prev (default \[aq]\[aq] and \[aq]\[aq]) +cmd-left (default \[aq]\[aq] and \[aq]\[aq]) +cmd-right (default \[aq]\[aq] and \[aq]\[aq]) +cmd-home (default \[aq]\[aq] and \[aq]\[aq]) +cmd-end (default \[aq]\[aq] and \[aq]\[aq]) +cmd-delete (default \[aq]\[aq] and \[aq]\[aq]) +cmd-delete-back (default \[aq]\[aq] and \[aq]\[aq]) +cmd-delete-home (default \[aq]\[aq]) +cmd-delete-end (default \[aq]\[aq]) +cmd-delete-unix-word (default \[aq]\[aq]) +cmd-yank (default \[aq]\[aq]) +cmd-transpose (default \[aq]\[aq]) +cmd-transpose-word (default \[aq]\[aq]) +cmd-word (default \[aq]\[aq]) +cmd-word-back (default \[aq]\[aq]) +cmd-delete-word (default \[aq]\[aq]) +cmd-delete-word-back (default \[aq]\[aq] and \[aq]\[aq]) +cmd-capitalize-word (default \[aq]\[aq]) +cmd-uppercase-word (default \[aq]\[aq]) +cmd-lowercase-word (default \[aq]\[aq]) \f[R] .fi .PP @@ -191,13 +190,13 @@ rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[ scrolloff int (default 0) selmode string (default \[aq]all\[aq]) shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows) -shellflag string (default \[aq]\-c\[aq] for Unix and \[aq]/c\[aq] for Windows) +shellflag string (default \[aq]-c\[aq] for Unix and \[aq]/c\[aq] for Windows) shellopts []string (default \[aq]\[aq]) sixel bool (default false) smartcase bool (default true) smartdia bool (default false) sortby string (default \[aq]natural\[aq]) -statfmt string (default \[dq]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| \-> %l\[dq]) +statfmt string (default \[dq]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| -> %l\[dq]) tabstop int (default 8) tagfmt string (default \[dq]\[rs]033[31m\[dq]) tempmarks string (default \[aq]\[aq]) @@ -245,11 +244,11 @@ open paste rename delete -pre\-cd -on\-cd -on\-select -on\-redraw -on\-quit +pre-cd +on-cd +on-select +on-redraw +on-quit \f[R] .fi .PP @@ -262,22 +261,22 @@ cmd open &$OPENER \[dq]$f\[dq] map e $$EDITOR \[dq]$f\[dq] map i $$PAGER \[dq]$f\[dq] map w $$SHELL -cmd doc $$lf \-doc | $PAGER -map doc -cmd maps $lf \-remote \[dq]query $id maps\[dq] | $PAGER -cmd cmaps $lf \-remote \[dq]query $id cmaps\[dq] | $PAGER -cmd cmds $lf \-remote \[dq]query $id cmds\[dq] | $PAGER +cmd doc $$lf -doc | $PAGER +map doc +cmd maps $lf -remote \[dq]query $id maps\[dq] | $PAGER +cmd cmaps $lf -remote \[dq]query $id cmaps\[dq] | $PAGER +cmd cmds $lf -remote \[dq]query $id cmds\[dq] | $PAGER Windows cmd open &%OPENER% %f% map e $%EDITOR% %f% map i !%PAGER% %f% map w $%SHELL% -cmd doc !%lf% \-doc | %PAGER% -map doc -cmd maps !%lf% \-remote \[dq]query %id% maps\[dq] | %PAGER% -cmd cmaps !%lf% \-remote \[dq]query %id% cmaps\[dq] | %PAGER% -cmd cmds !%lf% \-remote \[dq]query %id% cmds\[dq] | %PAGER% +cmd doc !%lf% -doc | %PAGER% +map doc +cmd maps !%lf% -remote \[dq]query %id% maps\[dq] | %PAGER% +cmd cmaps !%lf% -remote \[dq]query %id% cmaps\[dq] | %PAGER% +cmd cmds !%lf% -remote \[dq]query %id% cmds\[dq] | %PAGER% \f[R] .fi .PP @@ -323,33 +322,33 @@ Configuration files should be located at: .IP .nf \f[C] -OS system\-wide user\-specific +OS system-wide user-specific Unix /etc/lf/lfrc \[ti]/.config/lf/lfrc Windows C:\[rs]ProgramData\[rs]lf\[rs]lfrc C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]lfrc \f[R] .fi .PP -Colors file should be located at: +The colors file should be located at: .IP .nf \f[C] -OS system\-wide user\-specific +OS system-wide user-specific Unix /etc/lf/colors \[ti]/.config/lf/colors Windows C:\[rs]ProgramData\[rs]lf\[rs]colors C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]colors \f[R] .fi .PP -Icons file should be located at: +The icons file should be located at: .IP .nf \f[C] -OS system\-wide user\-specific +OS system-wide user-specific Unix /etc/lf/icons \[ti]/.config/lf/icons Windows C:\[rs]ProgramData\[rs]lf\[rs]icons C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]icons \f[R] .fi .PP -Selection file should be located at: +The selection file should be located at: .IP .nf \f[C] @@ -358,7 +357,7 @@ Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]files \f[R] .fi .PP -Marks file should be located at: +The marks file should be located at: .IP .nf \f[C] @@ -367,7 +366,7 @@ Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]marks \f[R] .fi .PP -Tags file should be located at: +The tags file should be located at: .IP .nf \f[C] @@ -376,7 +375,7 @@ Windows C:\[rs]Users\[rs]\[rs]AppData\[rs]Local\[rs]lf\[rs]tags \f[R] .fi .PP -History file should be located at: +The history file should be located at: .IP .nf \f[C] @@ -410,17 +409,17 @@ Windows .fi .PP A sample configuration file can be found at -https://github.com/gokcehan/lf/blob/master/etc/lfrc.example (https://github.com/gokcehan/lf/blob/master/etc/lfrc.example) + .SH COMMANDS .PP -This section shows information about builtin commands. +This section shows information about built-in commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings. .SS quit (default \f[C]q\f[R]) .PP Quit lf and return to the shell. -.SS up (default \f[C]k\f[R] and \f[C]\f[R]), half\-up (default \f[C]\f[R]), page\-up (default \f[C]\f[R] and \f[C]\f[R]), scroll\-up (default \f[C]\f[R]), down (default \f[C]j\f[R] and \f[C]\f[R]), half\-down (default \f[C]\f[R]), page\-down (default \f[C]\f[R] and \f[C]\f[R]), scroll\-down (default \f[C]\f[R]) +.SS up (default \f[C]k\f[R] and \f[C]\f[R]), half-up (default \f[C]\f[R]), page-up (default \f[C]\f[R] and \f[C]\f[R]), scroll-up (default \f[C]\f[R]), down (default \f[C]j\f[R] and \f[C]\f[R]), half-down (default \f[C]\f[R]), page-down (default \f[C]\f[R] and \f[C]\f[R]), scroll-down (default \f[C]\f[R]) .PP Move/scroll the current file selection upwards/downwards by one/half a page/full page. @@ -434,13 +433,13 @@ it, otherwise, execute the \f[C]open\f[R] command. A default \f[C]open\f[R] command is provided to call the default system opener asynchronously with the current file as the argument. A custom \f[C]open\f[R] command can be defined to override this default. -.SS jump\-next (default \f[C]]\f[R]), jump\-prev (default \f[C][\f[R]) +.SS jump-next (default \f[C]]\f[R]), jump-prev (default \f[C][\f[R]) .PP Change the current working directory to the next/previous jumplist item. .SS top (default \f[C]gg\f[R] and \f[C]\f[R]), bottom (default \f[C]G\f[R] and \f[C]\f[R]) .PP Move the current file selection to the top/bottom of the directory. -A count can be specified to move to a specific line, for example use +A count can be specified to move to a specific line, for example, use \f[C]3G\f[R] to move to the third line. .SS high (default \f[C]H\f[R]), middle (default \f[C]M\f[R]), low (default \f[C]L\f[R]) .PP @@ -452,12 +451,12 @@ Toggle the selection of the current file or files given as arguments. .PP Reverse the selection of all files in the current directory (i.e. \f[C]toggle\f[R] all files). -Selections in other directories are not effected by this command. +Selections in other directories are not affected by this command. You can define a new command to select all files in the directory by combining \f[C]invert\f[R] with \f[C]unselect\f[R] (i.e. -\f[C]cmd select\-all :unselect; invert\f[R]), though this will also +\f[C]cmd select-all :unselect; invert\f[R]), though this will also remove selections in other directories. -.SS invert\-below +.SS invert-below .PP Reverse the selection (i.e. \f[C]toggle\f[R]) of all files at or after the current file in the @@ -468,7 +467,7 @@ file you want to select. Then, move down to the first file you do \f[I]not\f[R] want to select (the one after the end of the desired selection) and use this command again. -This achieves an effect similar to the visual mode in vim. +This achieves an effect similar to the visual mode in Vim. .PP This command is experimental and may be removed once a better replacement for the visual mode is implemented in \f[C]lf\f[R]. @@ -478,7 +477,7 @@ it to a key (e.g. .SS unselect (default \f[C]u\f[R]) .PP Remove the selection of all files in all directories. -.SS glob\-select, glob\-unselect +.SS glob-select, glob-unselect .PP Select/unselect files that match the given glob. .SS calcdirsize @@ -487,7 +486,7 @@ Calculate the total size for each of the selected directories. Option \f[C]info\f[R] should include \f[C]size\f[R] and option \f[C]dircounts\f[R] should be disabled to show this size. If the total size of a directory is not calculated, it will be shown as -\f[C]\-\f[R]. +\f[C]-\f[R]. .SS clearmaps .PP Remove all keybindings associated with the \f[C]map\f[R] command. @@ -506,7 +505,7 @@ If there are no selections, save the path of the current file to the cut buffer, otherwise, copy the paths of selected files. .SS paste (default \f[C]p\f[R]) .PP -Copy/Move files in copy/cut buffer to the current working directory. +Copy/Move files in the copy/cut buffer to the current working directory. A custom \f[C]paste\f[R] command can be defined to override this default. .SS clear (default \f[C]c\f[R]) @@ -514,29 +513,29 @@ default. Clear file paths in copy/cut buffer. .SS sync .PP -Synchronize copied/cut files with server. +Synchronize copied/cut files with the server. This command is automatically called when required. .SS draw .PP Draw the screen. This command is automatically called when required. -.SS redraw (default \f[C]\f[R]) +.SS redraw (default \f[C]\f[R]) .PP Synchronize the terminal and redraw the screen. .SS load .PP Load modified files and directories. This command is automatically called when required. -.SS reload (default \f[C]\f[R]) +.SS reload (default \f[C]\f[R]) .PP Flush the cache and reload all files and directories. .SS echo .PP -Print given arguments to the message line at the bottom. +Print the given arguments to the message line at the bottom. .SS echomsg .PP -Print given arguments to the message line at the bottom and also to the -log file. +Print the given arguments to the message line at the bottom and also to +the log file. .SS echoerr .PP Print given arguments to the message line at the bottom as @@ -554,7 +553,7 @@ A custom \f[C]delete\f[R] command can be defined to override this default. .SS rename (modal) (default \f[C]r\f[R]) .PP -Rename the current file using the builtin method. +Rename the current file using the built-in method. A custom \f[C]rename\f[R] command can be defined to override this default. .SS source @@ -569,21 +568,21 @@ Read a command to evaluate. .SS shell (modal) (default \f[C]$\f[R]) .PP Read a shell command to execute. -.SS shell\-pipe (modal) (default \f[C]%\f[R]) +.SS shell-pipe (modal) (default \f[C]%\f[R]) .PP Read a shell command to execute piping its standard I/O to the bottom statline. -.SS shell\-wait (modal) (default \f[C]!\f[R]) +.SS shell-wait (modal) (default \f[C]!\f[R]) .PP Read a shell command to execute and wait for a key press in the end. -.SS shell\-async (modal) (default \f[C]&\f[R]) +.SS shell-async (modal) (default \f[C]&\f[R]) .PP Read a shell command to execute asynchronously without standard I/O. -.SS find (modal) (default \f[C]f\f[R]), find\-back (modal) (default \f[C]F\f[R]), find\-next (default \f[C];\f[R]), find\-prev (default \f[C],\f[R]) +.SS find (modal) (default \f[C]f\f[R]), find-back (modal) (default \f[C]F\f[R]), find-next (default \f[C];\f[R]), find-prev (default \f[C],\f[R]) .PP Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match. -.SS search (default \f[C]/\f[R]), search\-back (default \f[C]?\f[R]), search\-next (default \f[C]n\f[R]), search\-prev (default \f[C]N\f[R]) +.SS search (default \f[C]/\f[R]), search-back (default \f[C]?\f[R]), search-next (default \f[C]n\f[R]), search-prev (default \f[C]N\f[R]) .PP Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match. @@ -593,33 +592,33 @@ Command \f[C]filter\f[R] reads a pattern to filter out and only view files matching the pattern. Command \f[C]setfilter\f[R] does the same but uses an argument to set the filter immediately. -You can supply an argument to \f[C]filter\f[R], in order to use that as -the starting prompt. -.SS mark\-save (modal) (default \f[C]m\f[R]) +You can supply an argument to \f[C]filter\f[R] to use as the starting +prompt. +.SS mark-save (modal) (default \f[C]m\f[R]) .PP Save the current directory as a bookmark assigned to the given key. -.SS mark\-load (modal) (default \f[C]\[aq]\f[R]) +.SS mark-load (modal) (default \f[C]\[aq]\f[R]) .PP Change the current directory to the bookmark assigned to the given key. A special bookmark \f[C]\[aq]\f[R] holds the previous directory after a -\f[C]mark\-load\f[R], \f[C]cd\f[R], or \f[C]select\f[R] command. -.SS mark\-remove (modal) (default \f[C]\[dq]\f[R]) +\f[C]mark-load\f[R], \f[C]cd\f[R], or \f[C]select\f[R] command. +.SS mark-remove (modal) (default \f[C]\[dq]\f[R]) .PP Remove a bookmark assigned to the given key. .SS tag .PP -Tag a file with \f[C]*\f[R] or a single width character given in the +Tag a file with \f[C]*\f[R] or a single-width character given in the argument. -You can define a new tag clearing command by combining \f[C]tag\f[R] -with \f[C]tag\-toggle\f[R] (i.e. -\f[C]cmd tag\-clear :tag; tag\-toggle\f[R]). -.SS tag\-toggle (default \f[C]t\f[R]) +You can define a new tag-clearing command by combining \f[C]tag\f[R] +with \f[C]tag-toggle\f[R] (i.e. +\f[C]cmd tag-clear :tag; tag-toggle\f[R]). +.SS tag-toggle (default \f[C]t\f[R]) .PP Tag a file with \f[C]*\f[R] or a single width character given in the argument if the file is untagged, otherwise remove the tag. .SH COMMAND LINE COMMANDS .PP -The prompt character specifies which of the several command\-line modes +The prompt character specifies which of the several command-line modes you are in. For example, the \f[C]read\f[R] command takes you to the \f[C]:\f[R] mode. @@ -627,75 +626,75 @@ mode. When the cursor is at the first character in \f[C]:\f[R] mode, pressing one of the keys \f[C]!\f[R], \f[C]$\f[R], \f[C]%\f[R], or \f[C]&\f[R] takes you to the corresponding mode. -You can go back with \f[C]cmd\-delete\-back\f[R] (\f[C]\f[R] -by default). +You can go back with \f[C]cmd-delete-back\f[R] (\f[C]\f[R] by +default). .PP The command line commands should be mostly compatible with readline keybindings. -A character refers to a unicode code point, a word consists of letters -and digits, and a unix word consists of any non\-blank characters. -.SS cmd\-escape (default \f[C]\f[R]) +A character refers to a Unicode code point, a word consists of letters +and digits, and a unix word consists of any non-blank characters. +.SS cmd-escape (default \f[C]\f[R]) .PP Quit command line mode and return to normal mode. -.SS cmd\-complete (default \f[C]\f[R]) +.SS cmd-complete (default \f[C]\f[R]) .PP Autocomplete the current word. -.SS cmd\-menu\-complete, cmd\-menu\-complete\-back +.SS cmd-menu-complete, cmd-menu-complete-back .PP -Autocomplete the current word with menu selection. +Autocomplete the current word with the menu selection. You need to assign keys to these commands (e.g. -\f[C]cmap cmd\-menu\-complete; cmap cmd\-menu\-complete\-back\f[R]). -You can use the assigned keys assigned to display the menu and then -cycle through completion options. -.SS cmd\-menu\-accept +\f[C]cmap cmd-menu-complete; cmap cmd-menu-complete-back\f[R]). +You can use the assigned keys to display the menu and then cycle through +completion options. +.SS cmd-menu-accept .PP Accept the currently selected match in menu completion and close the menu. -.SS cmd\-enter (default \f[C]\f[R] and \f[C]\f[R]) +.SS cmd-enter (default \f[C]\f[R] and \f[C]\f[R]) .PP Execute the current line. -.SS cmd\-interrupt (default \f[C]\f[R]) +.SS cmd-interrupt (default \f[C]\f[R]) .PP -Interrupt the current shell\-pipe command and return to the normal mode. -.SS cmd\-history\-next (default \f[C]\f[R] and \f[C]\f[R]), cmd\-history\-prev (default \f[C]\f[R] and \f[C]\f[R]) +Interrupt the current shell-pipe command and return to the normal mode. +.SS cmd-history-next (default \f[C]\f[R] and \f[C]\f[R]), cmd-history-prev (default \f[C]\f[R] and \f[C]\f[R]) .PP -Go to next/previous item in the history. -.SS cmd\-left (default \f[C]\f[R] and \f[C]\f[R]), cmd\-right (default \f[C]\f[R] and \f[C]\f[R]) +Go to the next/previous item in the history. +.SS cmd-left (default \f[C]\f[R] and \f[C]\f[R]), cmd-right (default \f[C]\f[R] and \f[C]\f[R]) .PP Move the cursor to the left/right. -.SS cmd\-home (default \f[C]\f[R] and \f[C]\f[R]), cmd\-end (default \f[C]\f[R] and \f[C]\f[R]) +.SS cmd-home (default \f[C]\f[R] and \f[C]\f[R]), cmd-end (default \f[C]\f[R] and \f[C]\f[R]) .PP -Move the cursor to the beginning/end of line. -.SS cmd\-delete (default \f[C]\f[R] and \f[C]\f[R]) +Move the cursor to the beginning/end of the line. +.SS cmd-delete (default \f[C]\f[R] and \f[C]\f[R]) .PP Delete the next character. -.SS cmd\-delete\-back (default \f[C]\f[R] and \f[C]\f[R]) +.SS cmd-delete-back (default \f[C]\f[R] and \f[C]\f[R]) .PP Delete the previous character. When at the beginning of a prompt, returns either to normal mode or to \f[C]:\f[R] mode. -.SS cmd\-delete\-home (default \f[C]\f[R]), cmd\-delete\-end (default \f[C]\f[R]) +.SS cmd-delete-home (default \f[C]\f[R]), cmd-delete-end (default \f[C]\f[R]) .PP -Delete everything up to the beginning/end of line. -.SS cmd\-delete\-unix\-word (default \f[C]\f[R]) +Delete everything up to the beginning/end of the line. +.SS cmd-delete-unix-word (default \f[C]\f[R]) .PP Delete the previous unix word. -.SS cmd\-yank (default \f[C]\f[R]) +.SS cmd-yank (default \f[C]\f[R]) .PP Paste the buffer content containing the last deleted item. -.SS cmd\-transpose (default \f[C]\f[R]), cmd\-transpose\-word (default \f[C]\f[R]) +.SS cmd-transpose (default \f[C]\f[R]), cmd-transpose-word (default \f[C]\f[R]) .PP -Transpose the positions of last two characters/words. -.SS cmd\-word (default \f[C]\f[R]), cmd\-word\-back (default \f[C]\f[R]) +Transpose the positions of the last two characters/words. +.SS cmd-word (default \f[C]\f[R]), cmd-word-back (default \f[C]\f[R]) .PP -Move the cursor by one word in forward/backward direction. -.SS cmd\-delete\-word (default \f[C]\f[R]) +Move the cursor by one word in the forward/backward direction. +.SS cmd-delete-word (default \f[C]\f[R]) .PP -Delete the next word in forward direction. -.SS cmd\-delete\-word\-back (default \f[C]\f[R] and \f[C]\f[R]) +Delete the next word in the forward direction. +.SS cmd-delete-word-back (default \f[C]\f[R] and \f[C]\f[R]) .PP -Delete the previous word in backward direction. -.SS cmd\-capitalize\-word (default \f[C]\f[R]), cmd\-uppercase\-word (default \f[C]\f[R]), cmd\-lowercase\-word (default \f[C]\f[R]) +Delete the previous word in the backward direction. +.SS cmd-capitalize-word (default \f[C]\f[R]), cmd-uppercase-word (default \f[C]\f[R]), cmd-lowercase-word (default \f[C]\f[R]) .PP Capitalize/uppercase/lowercase the current word and jump to the next word. @@ -706,12 +705,12 @@ Character \f[C]:\f[R] is used as the separator for list options \f[C][]int\f[R] and \f[C][]string\f[R]. .SS anchorfind (bool) (default true) .PP -When this option is enabled, find command starts matching patterns from -the beginning of file names, otherwise, it can match at an arbitrary -position. +When this option is enabled, the find command starts matching patterns +from the beginning of file names, otherwise, it can match at an +arbitrary position. .SS autoquit (bool) (default false) .PP -Automatically quit server when there are no clients left connected. +Automatically quit the server when there are no clients left connected. .SS borderfmt (string) (default \f[C]\[rs]033[0m\f[R]) .PP Format string of the box drawing characters enabled by the @@ -721,7 +720,7 @@ Format string of the box drawing characters enabled by the Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and -the previously selected file had its preview cache disabled. +the previously selected file has its preview cache disabled. The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively. @@ -784,9 +783,9 @@ With the default format, copying a file \f[C]abc.txt\f[R] to the same directory will result in a duplicate file called \f[C]abc.txt.\[ti]1\[ti]\f[R]. Special expansions are provided, \f[C]%f\f[R] as the file name, -\f[C]%b\f[R] for basename (file name without extension), \f[C]%e\f[R] as -the extension (including the dot) and \f[C]%n\f[R] as the number of -duplicates. +\f[C]%b\f[R] for the basename (file name without extension), +\f[C]%e\f[R] as the extension (including the dot) and \f[C]%n\f[R] as +the number of duplicates. .SS errorfmt (string) (default \f[C]\[rs]033[7;31;47m\f[R]) .PP Format string of error messages shown in the bottom message line. @@ -808,7 +807,7 @@ single match left. .SS globsearch (bool) (default false) .PP When this option is enabled, search command patterns are considered as -globs, otherwise they are literals. +globs, otherwise, they are literals. With globbing, \f[C]*\f[R] matches any sequence, \f[C]?\f[R] matches any character, and \f[C][...]\f[R] or \f[C][\[ha]...]\f[R] matches character sets or ranges. @@ -844,8 +843,8 @@ It works by adding the assignment to the beginning of the command string as \f[C]IFS=...; ...\f[R]. The reason is that \f[C]IFS\f[R] variable is not inherited by the shell for security reasons. -This method assumes a POSIX shell syntax and so it can fail for -non\-POSIX shells. +This method assumes a POSIX shell syntax so it can fail for non-POSIX +shells. This option has no effect when the value is left empty. This option does not have any effect on Windows. .SS ignorecase (bool) (default true) @@ -862,7 +861,8 @@ Jump to the first match after each keystroke during searching. Apply filter pattern after each keystroke during filtering. .SS info ([]string) (default \[ga]\[ga]) .PP -List of information shown for directory items at the right side of pane. +A list of information that is shown for directory items at the right +side of the pane. Currently supported information types are \f[C]size\f[R], \f[C]time\f[R], \f[C]atime\f[R], and \f[C]ctime\f[R]. Information is only shown when the pane width is more than twice the @@ -880,10 +880,11 @@ doesn\[aq]t match this year. Send mouse events as input. .SS number (bool) (default false) .PP -Show the position number for directory items at the left side of pane. -When \f[C]relativenumber\f[R] option is enabled, only the current line -shows the absolute position and relative positions are shown for the -rest. +Show the position number for directory items on the left side of the +pane. +When the \f[C]relativenumber\f[R] option is enabled, only the current +line shows the absolute position and relative positions are shown for +the rest. .SS numberfmt (string) (default \f[C]\[rs]033[33m\f[R]) .PP Format string of the position number for each line. @@ -902,13 +903,13 @@ List of attributes that are preserved when copying files. Currently supported attributes are \f[C]mode\f[R] (i.a. access mode) and \f[C]timestamps\f[R] (i.e. modification time and access time). -Note, preserving other attribute like ownership of change/birth +Note that preserving other attributes like ownership of change/birth timestamp is desirable, but not portably supported in Go. .SS preview (bool) (default true) .PP -Show previews of files and directories at the right most pane. -If the file has more lines than the preview pane, rest of the lines are -not read. +Show previews of files and directories at the rightmost pane. +If the file has more lines than the preview pane, the rest of the lines +are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as \f[C]binary\f[R]. .SS previewer (string) (default \[ga]\[ga]) (not filtered if empty) @@ -920,7 +921,7 @@ The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. SIGPIPE signal is sent when enough lines are read. -If the previewer returns a non\-zero exit code, then the preview cache +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. @@ -930,26 +931,26 @@ the value of this option is left empty. .PP Format string of the prompt shown in the top line. Special expansions are provided, \f[C]%u\f[R] as the user name, -\f[C]%h\f[R] as the host name, \f[C]%w\f[R] as the working directory, +\f[C]%h\f[R] as the hostname, \f[C]%w\f[R] as the working directory, \f[C]%d\f[R] as the working directory with a trailing path separator, \f[C]%f\f[R] as the file name, and \f[C]%F\f[R] as the current filter. \f[C]%S\f[R] may be used once and will provide a spacer so that the following parts are right aligned on the screen. -Home folder is shown as \f[C]\[ti]\f[R] in the working directory +The home folder is shown as \f[C]\[ti]\f[R] in the working directory expansion. Directory names are automatically shortened to a single character -starting from the left most parent when the prompt does not fit to the +starting from the leftmost parent when the prompt does not fit the screen. .SS ratios ([]int) (default \f[C]1:2:3\f[R]) .PP List of ratios of pane widths. -Number of items in the list determines the number of panes in the ui. -When \f[C]preview\f[R] option is enabled, the right most number is used -for the width of preview pane. +Number of items in the list determines the number of panes in the UI. +When the \f[C]preview\f[R] option is enabled, the rightmost number is +used for the width of the preview pane. .SS relativenumber (bool) (default false) .PP Show the position number relative to the current line. -When \f[C]number\f[R] is enabled, current line shows the absolute +When \f[C]number\f[R] is enabled, the current line shows the absolute position, otherwise nothing is shown. .SS reverse (bool) (default false) .PP @@ -978,7 +979,7 @@ variables exported by lf. This is useful for displaying the current settings (e.g. \f[C]lf_selmode\f[R] displays the current setting for the \f[C]selmode\f[R] option). -User defined options starting with \f[C]lf_user_\f[R] are also +User-defined options starting with \f[C]lf_user_\f[R] are also supported, so it is possible to display information set from external sources. .SS rulerfmt (string) (default \f[C] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\f[R]) @@ -996,7 +997,7 @@ Additional expansions are provided for environment variables exported by lf, in the form \f[C]%{lf_}\f[R] (e.g. \f[C]%{lf_selmode}\f[R]). This is useful for displaying the current settings. -Expansions are also provided for user defined options, in the form +Expansions are also provided for user-defined options, in the form \f[C]%{lf_user_}\f[R] (e.g. \f[C]%{lf_user_foo}\f[R]). The \f[C]|\f[R] character splits the format string into sections. @@ -1011,8 +1012,8 @@ When set to \f[C]dir\f[R] it will only use the selected files in the current directory. .SS scrolloff (int) (default 0) .PP -Minimum number of offset lines shown at all times in the top and the -bottom of the screen when scrolling. +Minimum number of offset lines shown at all times at the top and 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 @@ -1021,8 +1022,8 @@ beginning or end of the list to show the maximum number of items. .PP Shell executable to use for shell commands. Shell commands are executed as -\f[C]shell shellopts shellflag command \-\- arguments\f[R]. -.SS shellflag (string) (default \f[C]\-c\f[R] for Unix and \f[C]/c\f[R] for Windows) +\f[C]shell shellopts shellflag command -- arguments\f[R]. +.SS shellflag (string) (default \f[C]-c\f[R] for Unix and \f[C]/c\f[R] for Windows) .PP Command line flag used to pass shell commands. .SS shellopts ([]string) (default \[ga]\[ga]) @@ -1047,13 +1048,13 @@ Sort type for directories. Currently supported sort types are \f[C]natural\f[R], \f[C]name\f[R], \f[C]size\f[R], \f[C]time\f[R], \f[C]ctime\f[R], \f[C]atime\f[R], and \f[C]ext\f[R]. -.SS statfmt (string) (default \f[C]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| \-> %l\f[R]) +.SS statfmt (string) (default \f[C]\[rs]033[36m%p\[rs]033[0m| %c| %u| %g| %S| %t| -> %l\f[R]) .PP Format string of the file info shown in the bottom left corner. Special expansions are provided, \f[C]%p\f[R] as the file permissions, \f[C]%c\f[R] as the link count, \f[C]%u\f[R] as the user, \f[C]%g\f[R] as the group, \f[C]%s\f[R] as the file size, \f[C]%S\f[R] as the file -size but with a fixed width of four characters (left\-padded with +size but with a fixed width of four characters (left-padded with spaces), \f[C]%t\f[R] as the last modified time, and \f[C]%l\f[R] as the link target. The \f[C]|\f[R] character splits the format string into sections. @@ -1086,12 +1087,12 @@ temporary and it does not need to be specified. Format string of the file modification time shown in the bottom line. .SS truncatechar (string) (default \f[C]\[ti]\f[R]) .PP -Truncate character shown at the end when the file name does not fit to -the pane. +The truncate character that is shown at the end when the file name does +not fit into the pane. .SS truncatepct (int) (default 100) .PP When a filename is too long to be shown completely, the available space -is partitioned in two pieces. +is partitioned into two pieces. truncatepct defines a fraction (in percent between 0 and 100) for the size of the first piece, which will show the beginning of the filename. The second piece will show the end of the filename and will use the rest @@ -1100,15 +1101,15 @@ Both pieces are separated by the truncation character (truncatechar). A value of 100 will only show the beginning of the filename, while a value of 0 will only show the end of the filename, e.g.: .IP \[bu] 2 -\f[C]set truncatepct 100\f[R] \-> -\f[C]very\-long\-filename\-tr\[ti]\f[R] (default) +\f[C]set truncatepct 100\f[R] -> \f[C]very-long-filename-tr\[ti]\f[R] +(default) .IP \[bu] 2 -\f[C]set truncatepct 50\f[R] \-> \f[C]very\-long\-f\[ti]\-truncated\f[R] +\f[C]set truncatepct 50\f[R] -> \f[C]very-long-f\[ti]-truncated\f[R] .IP \[bu] 2 -\f[C]set truncatepct 0\f[R] \-> \f[C]\[ti]ng\-filename\-truncated\f[R] +\f[C]set truncatepct 0\f[R] -> \f[C]\[ti]ng-filename-truncated\f[R] .SS waitmsg (string) (default \f[C]Press any key to continue\f[R]) .PP -String shown after commands of shell\-wait type. +String shown after commands of shell-wait type. .SS wrapscan (bool) (default true) .PP Searching can wrap around the file list. @@ -1117,17 +1118,17 @@ Searching can wrap around the file list. Scrolling can wrap around the file list. .SS user_{option} (string) (default none) .PP -Any option that is prefixed with \f[C]user_\f[R] is a user defined +Any option that is prefixed with \f[C]user_\f[R] is a user-defined option and can be set to any string. -Inside a user defined command the value will be provided in the +Inside a user-defined command, the value will be provided in the \f[C]lf_user_{option}\f[R] environment variable. These options are not used by lf and are not persisted. .SH ENVIRONMENT VARIABLES .PP The following variables are exported for shell commands: These are -referred with a \f[C]$\f[R] prefix on POSIX shells (e.g. +referred to with a \f[C]$\f[R] prefix on POSIX shells (e.g. \f[C]$f\f[R]), between \f[C]%\f[R] characters on Windows cmd (e.g. -\f[C]%f%\f[R]), and with a \f[C]$env:\f[R] prefix on Windows powershell +\f[C]%f%\f[R]), and with a \f[C]$env:\f[R] prefix on Windows PowerShell (e.g. \f[C]$env:f\f[R]). .SS f @@ -1159,14 +1160,14 @@ run lf from a shell spawned inside lf. You can add the value of this variable to your shell prompt to make it clear that your shell runs inside lf. For example, with POSIX shells, you can use -\f[C][ \-n \[dq]$LF_LEVEL\[dq] ] && PS1=\[dq]$PS1\[dq]\[dq](lf level: $LF_LEVEL) \[dq]\f[R] +\f[C][ -n \[dq]$LF_LEVEL\[dq] ] && PS1=\[dq]$PS1\[dq]\[dq](lf level: $LF_LEVEL) \[dq]\f[R] in your shell configuration file (e.g. \f[C]\[ti]/.bashrc\f[R]). .SS OPENER .PP If this variable is set in the environment, use the same value. Otherwise, this is set to \f[C]start\f[R] in Windows, \f[C]open\f[R] in -MacOS, \f[C]xdg\-open\f[R] in others. +MacOS, \f[C]xdg-open\f[R] in others. .SS EDITOR .PP If VISUAL is set in the environment, use its value. @@ -1218,25 +1219,25 @@ This shell command can be defined to override the default .PP This shell command can be defined to override the default \f[C]delete\f[R] command. -.SS pre\-cd +.SS pre-cd .PP This shell command can be defined to be executed before changing a directory. -.SS on\-cd +.SS on-cd .PP This shell command can be defined to be executed after changing a directory. -.SS on\-select +.SS on-select .PP This shell command can be defined to be executed after the selection changes. -.SS on\-redraw +.SS on-redraw .PP This shell command can be defined to be executed after the screen is redrawn or if the terminal is resized. -.SS on\-quit +.SS on-quit .PP -This shell command can be defined to be executed before quit. +This shell command can be defined to be executed before quitting. .SH PREFIXES .PP The following command prefixes are used by lf: @@ -1245,14 +1246,14 @@ The following command prefixes are used by lf: \f[C] : read (default) builtin/custom command $ shell shell command -% shell\-pipe shell command running with the ui -! shell\-wait shell command waiting for key press -& shell\-async shell command running asynchronously +% shell-pipe shell command running with the UI +! shell-wait shell command waiting for a key press +& shell-async shell command running asynchronously \f[R] .fi .PP The same evaluator is used for the command line and the configuration -file for read and shell commands. +file for reading 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. @@ -1269,7 +1270,7 @@ Characters from \f[C]#\f[R] to newline are comments and ignored: There are five special commands (\f[C]set\f[R], \f[C]setlocal\f[R], \f[C]map\f[R], \f[C]cmap\f[R], and \f[C]cmd\f[R]) for configuration. .PP -Command \f[C]set\f[R] is used to set an option which can be boolean, +Command \f[C]set\f[R] is used to set an option which can be a boolean, integer, or string: .IP .nf @@ -1287,7 +1288,7 @@ set sortby \[dq]time\[dq] # string value with double quotes (backslash escapes) .fi .PP Command \f[C]setlocal\f[R] is used to set a local option for a directory -which can be boolean or string. +which can be a boolean or string. Currently supported local options are \f[C]dirfirst\f[R], \f[C]dironly\f[R], \f[C]hidden\f[R], \f[C]info\f[R], \f[C]reverse\f[R], and \f[C]sortby\f[R]. @@ -1310,7 +1311,7 @@ setlocal /foo/bar/ hidden # for \[aq]/foo/bar\[aq] and its subdirectories \f[R] .fi .PP -Command \[aq]map\[aq] is used to bind a key to a command which can be +Command \[aq]map\[aq] is used to bind a key to a command which can be a builtin command, custom command, or shell command: .IP .nf @@ -1318,7 +1319,7 @@ builtin command, custom command, or shell command: map gh cd \[ti] # builtin command map D trash # custom command map i $less $f # shell command -map U !du \-csh * # waiting shell command +map U !du -csh * # waiting shell command \f[R] .fi .PP @@ -1327,8 +1328,8 @@ command line command or any other command: .IP .nf \f[C] -cmap cmd\-escape -cmap set incsearch! +cmap cmd-escape +cmap set incsearch! \f[R] .fi .PP @@ -1337,7 +1338,7 @@ You can delete an existing binding by leaving the expression empty: .nf \f[C] map gh # deletes \[aq]gh\[aq] mapping -cmap # deletes \[aq]\[aq] mapping +cmap # deletes \[aq]\[aq] mapping \f[R] .fi .PP @@ -1345,7 +1346,7 @@ Command \f[C]cmd\f[R] is used to define a custom command: .IP .nf \f[C] -cmd usage $du \-h \-d1 | less +cmd usage $du -h -d1 | less \f[R] .fi .PP @@ -1426,16 +1427,16 @@ Function keys are prefixed with \f[C]f\f[R] character: .IP .nf \f[C] -map down +map down \f[R] .fi .PP -Keys combined with the control key are prefixed with \f[C]c\f[R] +Keys combined with the control key are prefixed with a \f[C]c\f[R] character: .IP .nf \f[C] -map down +map down \f[R] .fi .PP @@ -1452,16 +1453,16 @@ map \['a] down .fi .PP Newer terminals (e.g. -gnome\-terminal) may prefix the key with an escape key when the alt key +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 +On these terminals, keys combined with the alt key are prefixed with an \f[C]a\f[R] character: .IP .nf \f[C] -map down +map down \f[R] .fi .PP @@ -1469,7 +1470,7 @@ It is possible to combine special keys with modifiers: .IP .nf \f[C] -map down +map down \f[R] .fi .PP @@ -1482,38 +1483,38 @@ The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the \f[C]unknown mapping\f[R] error. .PP -Mouse buttons are prefixed with \f[C]m\f[R] character: +Mouse buttons are prefixed with an \f[C]m\f[R] character: .IP .nf \f[C] -map down # primary -map down # secondary -map down # middle -map down -map down -map down -map down -map down +map down # primary +map down # secondary +map down # middle +map down +map down +map down +map down +map down \f[R] .fi .PP -Mouse wheel events are also prefixed with \f[C]m\f[R] character: +Mouse wheel events are also prefixed with an \f[C]m\f[R] character: .IP .nf \f[C] -map down -map down -map down -map down +map down +map down +map down +map down \f[R] .fi .SH PUSH MAPPINGS .PP 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 +While this provides a clean way to remap built-in keys as well as other commands, it can be limiting at times. -For this reason \f[C]push\f[R] command is provided by lf. +For this reason, the \f[C]push\f[R] command is provided by lf. This command is used to simulate key pushes given as its arguments. You can \f[C]map\f[R] a key to a \f[C]push\f[R] command with an argument to create various keybindings. @@ -1523,7 +1524,7 @@ First, it can be used to map a command with a command count: .IP .nf \f[C] -map push 10j +map push 10j \f[R] .fi .PP @@ -1536,9 +1537,9 @@ map r push :rename \f[R] .fi .PP -One thing to be careful is that since \f[C]push\f[R] command works with -keys instead of commands it is possible to accidentally create recursive -bindings: +One thing to be careful of is that since the \f[C]push\f[R] command +works with keys instead of commands it is possible to accidentally +create recursive bindings: .IP .nf \f[C] @@ -1551,15 +1552,15 @@ These types of bindings create a deadlock when executed. .PP 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. +For example, we can write a shell command to move the selected file(s) +to trash. A first attempt to write such a command may look like this: .IP .nf \f[C] cmd trash ${{ - mkdir \-p \[ti]/.trash - if [ \-z \[dq]$fs\[dq] ]; then + mkdir -p \[ti]/.trash + if [ -z \[dq]$fs\[dq] ]; then mv \[dq]$f\[dq] \[ti]/.trash else IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fs \[ti]/.trash @@ -1569,7 +1570,7 @@ cmd trash ${{ .fi .PP We check \f[C]$fs\f[R] to see if there are any selected files. -Otherwise we just delete the current file. +Otherwise, we just delete the current file. Since this is such a common pattern, a separate \f[C]$fx\f[R] variable is provided. We can use this variable to get rid of the conditional: @@ -1577,7 +1578,7 @@ We can use this variable to get rid of the conditional: .nf \f[C] cmd trash ${{ - mkdir \-p \[ti]/.trash + mkdir -p \[ti]/.trash IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash }} \f[R] @@ -1589,25 +1590,25 @@ startup: .IP .nf \f[C] -${{ mkdir \-p \[ti]/.trash }} +${{ mkdir -p \[ti]/.trash }} cmd trash ${{ IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash }} \f[R] .fi .PP -Since these are one liners, we can drop \f[C]{{\f[R] and \f[C]}}\f[R]: +Since these are one-liners, we can drop \f[C]{{\f[R] and \f[C]}}\f[R]: .IP .nf \f[C] -$mkdir \-p \[ti]/.trash +$mkdir -p \[ti]/.trash cmd trash $IFS=\[dq]$(printf \[aq]\[rs]n\[rs]t\[aq])\[dq]; mv $fx \[ti]/.trash \f[R] .fi .PP -Finally note that we set \f[C]IFS\f[R] variable manually in these +Finally, note that we set the \f[C]IFS\f[R] variable manually in these commands. -Instead we could use the \f[C]ifs\f[R] option to set it for all shell +Instead, we could use the \f[C]ifs\f[R] option to set it for all shell commands (i.e. \f[C]set ifs \[dq]\[rs]n\[dq]\f[R]). This can be especially useful for interactive use (e.g. @@ -1622,13 +1623,13 @@ 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 +Also, even when there is no output or error, the UI still needs to be paused while the command is running. This can cause flickering on the screen for short commands and similar distractions for longer commands. .PP -Instead of pausing the ui, piping shell commands connects stdin, stdout, -and stderr of the command to the statline in the bottom of the ui. +Instead of pausing the UI, piping shell commands connect stdin, stdout, +and stderr of the command to the statline at 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. @@ -1638,7 +1639,7 @@ statline if there is an existing file with the given name: .IP .nf \f[C] -cmd rename %mv \-i $f $1 +cmd rename %mv -i $f $1 \f[R] .fi .PP @@ -1648,7 +1649,7 @@ For example, an alternative rename command may look like this: .IP .nf \f[C] -cmd rename %[ \-e $1 ] && printf \[dq]file exists\[dq] || mv $f $1 +cmd rename %[ -e $1 ] && printf \[dq]file exists\[dq] || mv $f $1 \f[R] .fi .PP @@ -1657,7 +1658,7 @@ Note that input is line buffered and output and error are byte buffered. .PP Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. -These can be useful to see the output of a program before the ui is +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 @@ -1667,8 +1668,8 @@ multiline. 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. +Stdin, stdout, and stderr of the command are neither connected to the +terminal nor the UI. .SH REMOTE COMMANDS .PP One of the more advanced features in lf is remote commands. @@ -1685,7 +1686,7 @@ You can use it to send a command to the socket file: .IP .nf \f[C] -echo \[aq]send echo hello world\[aq] | nc \-U ${XDG_RUNTIME_DIR:\-/tmp}/lf.${USER}.sock +echo \[aq]send echo hello world\[aq] | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock \f[R] .fi .PP @@ -1698,18 +1699,18 @@ and immune to socket file address changes: .IP .nf \f[C] -lf \-remote \[aq]send echo hello world\[aq] +lf -remote \[aq]send echo hello world\[aq] \f[R] .fi .PP In this command \f[C]send\f[R] is used to send the rest of the string as a command to all connected clients. -You can optionally give it an id number to send a command to a single +You can optionally give it an ID number to send a command to a single client: .IP .nf \f[C] -lf \-remote \[aq]send 1234 echo hello world\[aq] +lf -remote \[aq]send 1234 echo hello world\[aq] \f[R] .fi .PP @@ -1717,7 +1718,7 @@ All clients have a unique id number but you may not be aware of the id number when you are writing a command. For this purpose, an \f[C]$id\f[R] variable is exported to the environment for shell commands. -The value of this variable is set to the process id of the client. +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 @@ -1725,24 +1726,24 @@ following in a shell command: .IP .nf \f[C] -lf \-remote \[dq]send $id echo hello world\[dq] +lf -remote \[dq]send $id echo hello world\[dq] \f[R] .fi .PP Since lf does not have control flow syntax, remote commands are used for such needs. -For example, you can configure the number of columns in the ui with +For example, you can configure the number of columns in the UI with respect to the terminal width as follows: .IP .nf \f[C] cmd recol %{{ - if [ $lf_width \-le 80 ]; then - lf \-remote \[dq]send $id set ratios 1:2\[dq] - elif [ $lf_width \-le 160 ]; then - lf \-remote \[dq]send $id set ratios 1:2:3\[dq] + if [ $lf_width -le 80 ]; then + lf -remote \[dq]send $id set ratios 1:2\[dq] + elif [ $lf_width -le 160 ]; then + lf -remote \[dq]send $id set ratios 1:2:3\[dq] else - lf \-remote \[dq]send $id set ratios 1:2:3:5\[dq] + lf -remote \[dq]send $id set ratios 1:2:3:5\[dq] fi }} \f[R] @@ -1753,7 +1754,7 @@ information about a specific lf instance by providing its id: .IP .nf \f[C] -lf \-remote \[dq]query $id maps\[dq] +lf -remote \[dq]query $id maps\[dq] \f[R] .fi .PP @@ -1774,15 +1775,15 @@ For example, to select a previous command using fzf and execute it: .IP .nf \f[C] -map ${{ +map ${{ clear cmd=$( - lf \-remote \[dq]query $id history\[dq] | - awk \-F\[aq]\[rs]t\[aq] \[aq]NR > 1 { print $NF}\[aq] | - sort \-u | - fzf \-\-reverse \-\-prompt=\[aq]Execute command: \[aq] + lf -remote \[dq]query $id history\[dq] | + awk -F\[aq]\[rs]t\[aq] \[aq]NR > 1 { print $NF}\[aq] | + sort -u | + fzf --reverse --prompt=\[aq]Execute command: \[aq] ) - lf \-remote \[dq]send $id $cmd\[dq] + lf -remote \[dq]send $id $cmd\[dq] }} \f[R] .fi @@ -1793,36 +1794,37 @@ the server by closing client connections first: .IP .nf \f[C] -lf \-remote \[aq]quit\[aq] -lf \-remote \[aq]quit!\[aq] +lf -remote \[aq]quit\[aq] +lf -remote \[aq]quit!\[aq] \f[R] .fi .PP -Lastly, there is a \f[C]conn\f[R] command to connect the server as a +Lastly, there is a \f[C]conn\f[R] command to connect the server to a client. This should not be needed for users. .SH FILE OPERATIONS .PP -lf uses its own builtin copy and move operations by default. +lf uses its own built-in copy and move operations by default. These are implemented as asynchronous operations and progress is shown in the bottom ruler. These commands do not overwrite existing files or directories with the same name. -Instead, a suffix that is compatible with \f[C]\-\-backup=numbered\f[R] -option in GNU cp is added to the new files or directories. +Instead, a suffix that is compatible with the +\f[C]--backup=numbered\f[R] option in GNU cp is added to the new files +or directories. Only file modes and (some) timestamps can be preserved (see \f[C]preserve\f[R] option), all other attributes are ignored including ownership, context, and xattr. Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed. Moving is performed using the rename operation of the underlying OS. -For cross\-device moving, lf falls back to copying and then deletes the +For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors. Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation. .PP -File operations can be performed on the current selected file or -alternatively on multiple files by selecting them first. +File operations can be performed on the currently selected file or on +multiple files by selecting them first. When you \f[C]copy\f[R] a file, lf doesn\[aq]t actually copy the file on the disk, but only records its name to a file. The actual file copying takes place when you \f[C]paste\f[R]. @@ -1832,30 +1834,29 @@ file. You can customize copy and move operations by defining a \f[C]paste\f[R] command. This is a special command that is called when it is defined instead of -the builtin implementation. +the built-in implementation. You can use the following example as a starting point: .IP .nf \f[C] cmd paste %{{ load=$(cat \[ti]/.local/share/lf/files) - mode=$(echo \[dq]$load\[dq] | sed \-n \[aq]1p\[aq]) + mode=$(echo \[dq]$load\[dq] | sed -n \[aq]1p\[aq]) list=$(echo \[dq]$load\[dq] | sed \[aq]1d\[aq]) if [ $mode = \[aq]copy\[aq] ]; then - cp \-R $list . + cp -R $list . elif [ $mode = \[aq]move\[aq] ]; then mv $list . rm \[ti]/.local/share/lf/files - lf \-remote \[aq]send clear\[aq] + lf -remote \[aq]send clear\[aq] fi }} \f[R] .fi .PP Some useful things to be considered are to use the backup -(\f[C]\-\-backup\f[R]) and/or preserve attributes (\f[C]\-a\f[R]) -options with \f[C]cp\f[R] and \f[C]mv\f[R] commands if they support it -(i.e. +(\f[C]--backup\f[R]) and/or preserve attributes (\f[C]-a\f[R]) options +with \f[C]cp\f[R] and \f[C]mv\f[R] commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use \f[C]rsync\f[R] command with progress bar option for copying and feed the progress to the client periodically with remote \f[C]echo\f[R] @@ -1866,8 +1867,8 @@ protect new users. You can customize file deletion by defining a \f[C]delete\f[R] command. You can also assign a key to this command if you like. An example command to move selected files to a trash folder and remove -files completely after a prompt are provided in the example -configuration file. +files completely after a prompt is provided in the example configuration +file. .SH SEARCHING FILES .PP There are two mechanisms implemented in lf to search a file in the @@ -1877,9 +1878,9 @@ matching a given pattern. Finding is an alternative way to search for a pattern possibly using fewer keystrokes. .PP -Searching mechanism is implemented with commands \f[C]search\f[R] -(default \f[C]/\f[R]), \f[C]search\-back\f[R] (default \f[C]?\f[R]), -\f[C]search\-next\f[R] (default \f[C]n\f[R]), and \f[C]search\-prev\f[R] +The searching mechanism is implemented with commands \f[C]search\f[R] +(default \f[C]/\f[R]), \f[C]search-back\f[R] (default \f[C]?\f[R]), +\f[C]search-next\f[R] (default \f[C]n\f[R]), and \f[C]search-prev\f[R] (default \f[C]N\f[R]). You can enable \f[C]globsearch\f[R] option to match with a glob pattern. Globbing supports \f[C]*\f[R] to match any sequence, \f[C]?\f[R] to @@ -1887,8 +1888,8 @@ match any character, and \f[C][...]\f[R] or \f[C][\[ha]...]\f[R] to match character sets or ranges. You can enable \f[C]incsearch\f[R] option to jump to the current match at each keystroke while typing. -In this mode, you can either use \f[C]cmd\-enter\f[R] to accept the -search or use \f[C]cmd\-escape\f[R] to cancel the search. +In this mode, you can either use \f[C]cmd-enter\f[R] to accept the +search or use \f[C]cmd-escape\f[R] to cancel the search. You can also map some other commands with \f[C]cmap\f[R] to accept the search and execute the command immediately afterwards. For example, you can use the right arrow key to finish the search and @@ -1896,38 +1897,38 @@ open the selected file with the following mapping: .IP .nf \f[C] -cmap :cmd\-enter; open +cmap :cmd-enter; open \f[R] .fi .PP -Finding mechanism is implemented with commands \f[C]find\f[R] (default -\f[C]f\f[R]), \f[C]find\-back\f[R] (default \f[C]F\f[R]), -\f[C]find\-next\f[R] (default \f[C];\f[R]), \f[C]find\-prev\f[R] -(default \f[C],\f[R]). +The finding mechanism is implemented with commands \f[C]find\f[R] +(default \f[C]f\f[R]), \f[C]find-back\f[R] (default \f[C]F\f[R]), +\f[C]find-next\f[R] (default \f[C];\f[R]), \f[C]find-prev\f[R] (default +\f[C],\f[R]). You can disable \f[C]anchorfind\f[R] option to match a pattern at an arbitrary position in the filename instead of the beginning. You can set the number of keys to match using \f[C]findlen\f[R] option. -If you set this value to zero, then the the keys are read until there is +If you set this value to zero, then 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. +The default values of these two options are set to jump to the first +file with the given initial. .PP Some options effect both searching and finding. -You can disable \f[C]wrapscan\f[R] option to prevent searches to wrap -around at the end of the file list. +You can disable \f[C]wrapscan\f[R] option to prevent searches from being +wrapped around at the end of the file list. You can disable \f[C]ignorecase\f[R] option to match cases in the pattern and the filename. This option is already automatically overridden if the pattern contains -upper case characters. +upper-case characters. You can disable \f[C]smartcase\f[R] option to disable this behavior. Two similar options \f[C]ignoredia\f[R] and \f[C]smartdia\f[R] are -provided to control matching diacritics in latin letters. +provided to control matching diacritics in Latin letters. .SH OPENING FILES .PP -You can define a an \f[C]open\f[R] command (default \f[C]l\f[R] and +You can define an \f[C]open\f[R] command (default \f[C]l\f[R] and \f[C]\f[R]) to configure file opening. This command is only called when the current file is not a directory, -otherwise the directory is entered instead. +otherwise, the directory is entered instead. You can define it just as you would define any other command: .IP .nf @@ -1940,7 +1941,7 @@ It is possible to use different command types: .IP .nf \f[C] -cmd open &xdg\-open $f +cmd open &xdg-open $f \f[R] .fi .PP @@ -1950,9 +1951,9 @@ You may want to use either file extensions or mime types from .nf \f[C] cmd open ${{ - case $(file \-\-mime\-type \-Lb $f) in + case $(file --mime-type -Lb $f) in text/*) vi $fx;; - *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; esac }} \f[R] @@ -1962,28 +1963,28 @@ You may want to use \f[C]setsid\f[R] before your opener command to have persistent processes that continue to run after lf quits. .PP Regular shell commands (i.e. -\f[C]$\f[R]) drop to terminal which results in a flicker for commands -that finishes immediately (e.g. -\f[C]xdg\-open\f[R] in the above example). +\f[C]$\f[R]) drop to the terminal which results in a flicker for +commands that finish immediately (e.g. +\f[C]xdg-open\f[R] in the above example). If you want to use asynchronous shell commands (i.e. \f[C]&\f[R]) but also want to use the terminal when necessary (e.g. -\f[C]vi\f[R] in the above exxample), you can use a remote command: +\f[C]vi\f[R] in the above example), you can use a remote command: .IP .nf \f[C] cmd open &{{ - case $(file \-\-mime\-type \-Lb $f) in - text/*) lf \-remote \[dq]send $id \[rs]$vi \[rs]$fx\[dq];; - *) for f in $fx; do xdg\-open $f > /dev/null 2> /dev/null & done;; + case $(file --mime-type -Lb $f) in + text/*) lf -remote \[dq]send $id \[rs]$vi \[rs]$fx\[dq];; + *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;; esac }} \f[R] .fi .PP -Note, asynchronous shell commands run in their own process group by +Note that asynchronous shell commands run in their own process group by default so they do not require the manual use of \f[C]setsid\f[R]. .PP -Following command is provided by default: +The following command is provided by default: .IP .nf \f[C] @@ -1992,31 +1993,31 @@ cmd open &$OPENER $f .fi .PP You may also use any other existing file openers as you like. -Possible options are \f[C]libfile\-mimeinfo\-perl\f[R] (executable name -is \f[C]mimeopen\f[R]), \f[C]rifle\f[R] (ranger\[aq]s default file -opener), or \f[C]mimeo\f[R] to name a few. +Possible options are \f[C]libfile-mimeinfo-perl\f[R] (executable name is +\f[C]mimeopen\f[R]), \f[C]rifle\f[R] (ranger\[aq]s default file opener), +or \f[C]mimeo\f[R] to name a few. .SH PREVIEWING FILES .PP lf previews files on the preview pane by printing the file until the end -or the preview pane is filled. +or until 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. +files or view PDF or image files to name a few. +For coloring lf recognizes ANSI escape codes. .PP -In order to use this feature you need to set the value of -\f[C]previewer\f[R] option to the path of an executable file. +To use this feature, you need to set the value of \f[C]previewer\f[R] +option to the path of an executable file. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. -Output of the execution is printed in the preview pane. +The output of the execution is printed in the preview pane. You may also want to use the same script in your pager mapping as well: .IP .nf \f[C] set previewer \[ti]/.config/lf/pv.sh -map i $\[ti]/.config/lf/pv.sh $f | less \-R +map i $\[ti]/.config/lf/pv.sh $f | less -R \f[R] .fi .PP @@ -2027,7 +2028,7 @@ path of the file can still be displayed in the statusline below: .nf \f[C] set previewer \[ti]/.config/lf/pv.sh -map i $LESSOPEN=\[aq]| \[ti]/.config/lf/pv.sh %s\[aq] less \-R $f +map i $LESSOPEN=\[aq]| \[ti]/.config/lf/pv.sh %s\[aq] less -R $f \f[R] .fi .PP @@ -2044,11 +2045,11 @@ Extensions can then be used to match cleanly within a conditional: case \[dq]$1\[dq] in *.tar*) tar tf \[dq]$1\[dq];; - *.zip) unzip \-l \[dq]$1\[dq];; + *.zip) unzip -l \[dq]$1\[dq];; *.rar) unrar l \[dq]$1\[dq];; *.7z) 7z l \[dq]$1\[dq];; - *.pdf) pdftotext \[dq]$1\[dq] \-;; - *) highlight \-O ansi \[dq]$1\[dq];; + *.pdf) pdftotext \[dq]$1\[dq] -;; + *) highlight -O ansi \[dq]$1\[dq];; esac \f[R] .fi @@ -2057,21 +2058,21 @@ Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, \f[C]highlight\f[R] is recommended over \f[C]pygmentize\f[R] for syntax highlighting. -Besides, it is also important that the application is processing the -file on the fly rather than first reading it to the memory and then do -the processing afterwards. +Besides, it is also important that the application processes the file on +the fly rather than first reading it to the memory and then doing the +processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a -non\-zero return code and avoid caching. +non-zero return code and avoid caching. You may add a trailing \f[C]|| true\f[R] command to avoid such errors: .IP .nf \f[C] -highlight \-O ansi \[dq]$1\[dq] || true +highlight -O ansi \[dq]$1\[dq] || true \f[R] .fi .PP @@ -2079,7 +2080,7 @@ You may also use an existing preview filter as you like. Your system may already come with a preview filter named \f[C]lesspipe\f[R]. These filters may have a mechanism to add user customizations as well. -See the related documentations for more information. +See the related documentation for more information. .SH CHANGING DIRECTORY .PP lf changes the working directory of the process to the current directory @@ -2088,26 +2089,25 @@ After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository -at -https://github.com/gokcehan/lf/tree/master/etc (https://github.com/gokcehan/lf/tree/master/etc) +at .PP -There is a special command \f[C]on\-cd\f[R] that runs a shell command +There is a special command \f[C]on-cd\f[R] that runs a shell command when it is defined and the directory is changed. You can define it just as you would define any other command: .IP .nf \f[C] -cmd on\-cd &{{ - bash \-c \[aq] +cmd on-cd &{{ + bash -c \[aq] # display git repository status in your prompt - source /usr/share/git/completion/git\-prompt.sh + source /usr/share/git/completion/git-prompt.sh GIT_PS1_SHOWDIRTYSTATE=auto GIT_PS1_SHOWSTASHSTATE=auto GIT_PS1_SHOWUNTRACKEDFILES=auto GIT_PS1_SHOWUPSTREAM=auto git=$(__git_ps1 \[dq] (%s)\[dq]) fmt=\[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\[rs]033[34;1m%d\[rs]033[0m\[rs]033[1m%f$git\[rs]033[0m\[dq] - lf \-remote \[dq]send $id set promptfmt \[rs]\[dq]$fmt\[rs]\[dq]\[dq] + lf -remote \[dq]send $id set promptfmt \[rs]\[dq]$fmt\[rs]\[dq]\[dq] \[aq] }} \f[R] @@ -2115,24 +2115,24 @@ cmd on\-cd &{{ .PP If you want to print escape sequences, you may redirect \f[C]printf\f[R] output to \f[C]/dev/tty\f[R]. -The following xterm specific escape sequence sets the terminal title to +The following xterm-specific escape sequence sets the terminal title to the working directory: .IP .nf \f[C] -cmd on\-cd &{{ +cmd on-cd &{{ printf \[dq]\[rs]033]0; $PWD\[rs]007\[dq] > /dev/tty }} \f[R] .fi .PP -This command runs whenever you change directory but not on startup. +This command runs whenever you change the directory but not on startup. You can add an extra call to make it run on startup as well: .IP .nf \f[C] -cmd on\-cd &{{ ... }} -on\-cd +cmd on-cd &{{ ... }} +on-cd \f[R] .fi .PP @@ -2140,12 +2140,12 @@ Note that all shell commands are possible but \f[C]%\f[R] and \f[C]&\f[R] are usually more appropriate as \f[C]$\f[R] and \f[C]!\f[R] causes flickers and pauses respectively. .PP -There is also a \f[C]pre\-cd\f[R] command, that works like -\f[C]on\-cd\f[R], but is run before the directory is actually changed. +There is also a \f[C]pre-cd\f[R] command, that works like +\f[C]on-cd\f[R], but is run before the directory is actually changed. .SH COLORS .PP lf tries to automatically adapt its colors to the environment. -It starts with a default colorscheme and updates colors using values of +It starts with a default color scheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order: @@ -2167,31 +2167,32 @@ Please refer to the corresponding man pages for more information about not ls. This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases. -Colors file is provided for easier configuration without environment -variables. -This file should consist of whitespace separated pairs with \f[C]#\f[R] -character to start comments until the end of line. +The colors file (refer to the CONFIGURATION +section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) +is provided for easier configuration without environment variables. +This file should consist of whitespace-separated pairs with a +\f[C]#\f[R] character to start comments until the end of the line. .PP You can configure lf colors in two different ways. First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors -from a 24\-bit palette. +from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other. .PP Second, you can set the values of environment variables or colors file -mentioned above for fine grained customization. +mentioned above for fine-grained customization. Note that \f[C]LS_COLORS/LF_COLORS\f[R] are more powerful than \f[C]LSCOLORS\f[R] and they can be used even when GNU programs are not installed on the system. -You can combine this second method with the first method for best +You can combine this second method with the first method for the best results. .PP Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. Colors of the prompt line can be configured using the -\f[C]promptfmt\f[R] option which can include hardcoded colors as ansi +\f[C]promptfmt\f[R] option which can include hardcoded colors as ANSI escapes. See the default value of this option to have an idea about how to color this line. @@ -2199,11 +2200,11 @@ this line. It is worth noting that lf uses as many colors advertised by your terminal\[aq]s entry in terminfo or infocmp databases on your system. If an entry is not present, it falls back to an internal database. -If your terminal supports 24\-bit colors but either does not have a +If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the \f[C]$COLORTERM\f[R] variable to \f[C]truecolor\f[R] or ensuring \f[C]$TERM\f[R] is set to a value that -ends with \f[C]\-truecolor\f[R]. +ends with \f[C]-truecolor\f[R]. .PP Default lf colors are mostly taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute. @@ -2300,8 +2301,8 @@ used: .IP "8." 3 \f[C]fi\f[R] .PP -Note that glob\-like patterns do not actually perform glob matching due -to performance reasons. +Note that glob-like patterns do not perform glob matching for +performance reasons. .PP For example, you can set a variable as follows: .IP @@ -2312,8 +2313,8 @@ export LF_COLORS=\[dq]\[ti]/Documents=01;31:\[ti]/Downloads=01;31:\[ti]/.local/s .fi .PP Having all entries on a single line can make it hard to read. -You may instead divide it to multiple lines in between double quotes by -escaping newlines with backslashes as follows: +You may instead divide it into multiple lines in between double quotes +by escaping newlines with backslashes as follows: .IP .nf \f[C] @@ -2338,21 +2339,27 @@ ex=01;32:\[rs] .PP Having such a long variable definition in a shell configuration file might be undesirable. -You may instead use the colors file for configuration. +You may instead use the colors file (refer to the CONFIGURATION +section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) +for configuration. A sample colors file can be found at -https://github.com/gokcehan/lf/blob/master/etc/colors.example (https://github.com/gokcehan/lf/blob/master/etc/colors.example) -You may also see the wiki page for ansi escape codes -https://en.wikipedia.org/wiki/ANSI_escape_code (https://en.wikipedia.org/wiki/ANSI_escape_code) + You may +also see the wiki page for ANSI escape codes + .SH ICONS .PP Icons are configured using \f[C]LF_ICONS\f[R] environment variable or an -icons file. +icons file (refer to the CONFIGURATION +section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration)). The variable uses the same syntax as \f[C]LS_COLORS/LF_COLORS\f[R]. Instead of colors, you should put a single characters as values of entries. -Icons file should consist of whitespace separated pairs with \f[C]#\f[R] -character to start comments until the end of line. -Do not forget to enable \f[C]icons\f[R] option to see the icons. +The icons file (refer to the CONFIGURATION +section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) +should consist of whitespace-separated pairs with a \f[C]#\f[R] +character to start comments until the end of the line. +Do not forget to add \f[C]set icons true\f[R] to your \f[C]lfrc\f[R] to +see the icons. Default values are as follows given with their matching order in lf: .IP .nf @@ -2370,9 +2377,9 @@ cd c su u sg g ex x -fi \- +fi - \f[R] .fi .PP A sample icons file can be found at -https://github.com/gokcehan/lf/blob/master/etc/icons.example (https://github.com/gokcehan/lf/blob/master/etc/icons.example) + diff --git a/opts.go b/opts.go index f14f2c62..788a34ae 100644 --- a/opts.go +++ b/opts.go @@ -31,69 +31,70 @@ type sortType struct { } var gOpts struct { - anchorfind bool - autoquit bool - borderfmt string - cursoractivefmt string - cursorparentfmt string - cursorpreviewfmt string - dircache bool - dircounts bool - dironly bool - dirpreviews bool - drawbox bool - dupfilefmt string - globsearch bool - icons bool - ignorecase bool - ignoredia bool - incfilter bool - incsearch bool - mouse bool - number bool - preview bool - sixel bool - relativenumber bool - smartcase bool - smartdia bool - waitmsg string - wrapscan bool - wrapscroll bool - findlen int - period int - scrolloff int - tabstop int - errorfmt string - filesep string - ifs string - previewer string - cleaner string - promptfmt string - selmode string - shell string - shellflag string - statfmt string - timefmt string - infotimefmtnew string - infotimefmtold string - truncatechar string - truncatepct int - ratios []int - hiddenfiles []string - history bool - info []string - ruler []string - rulerfmt string - preserve []string - shellopts []string - keys map[string]expr - cmdkeys map[string]expr - cmds map[string]expr - user map[string]string - sortType sortType - tempmarks string - numberfmt string - tagfmt string + anchorfind bool + autoquit bool + borderfmt string + cursoractivefmt string + cursorparentfmt string + cursorpreviewfmt string + hidecursorinactive bool + dircache bool + dircounts bool + dironly bool + dirpreviews bool + drawbox bool + dupfilefmt string + globsearch bool + icons bool + ignorecase bool + ignoredia bool + incfilter bool + incsearch bool + mouse bool + number bool + preview bool + sixel bool + relativenumber bool + smartcase bool + smartdia bool + waitmsg string + wrapscan bool + wrapscroll bool + findlen int + period int + scrolloff int + tabstop int + errorfmt string + filesep string + ifs string + previewer string + cleaner string + promptfmt string + selmode string + shell string + shellflag string + statfmt string + timefmt string + infotimefmtnew string + infotimefmtold string + truncatechar string + truncatepct int + ratios []int + hiddenfiles []string + history bool + info []string + ruler []string + rulerfmt string + preserve []string + shellopts []string + keys map[string]expr + cmdkeys map[string]expr + cmds map[string]expr + user map[string]string + sortType sortType + tempmarks string + numberfmt string + tagfmt string } var gLocalOpts struct { @@ -194,6 +195,7 @@ func init() { gOpts.cursoractivefmt = "\033[7m" gOpts.cursorparentfmt = "\033[7m" gOpts.cursorpreviewfmt = "\033[4m" + gOpts.hidecursorinactive = false gOpts.globsearch = false gOpts.icons = false gOpts.ignorecase = true diff --git a/ui.go b/ui.go index 9a181201..29b67936 100644 --- a/ui.go +++ b/ui.go @@ -353,7 +353,7 @@ const SelectionColor = tcell.ColorPurple const YankColor = tcell.ColorOlive const CutColor = tcell.ColorMaroon -func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dirStyle *dirStyle, previewLoading bool) { +func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirStyle, previewLoading bool) { if win.w < 5 || dir == nil { return } @@ -361,12 +361,12 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir messageStyle := tcell.StyleDefault.Reverse(true) if dir.noPerm { - win.print(screen, 2, 0, messageStyle, "permission denied") + win.print(ui.screen, 2, 0, messageStyle, "permission denied") return } if (dir.loading && len(dir.files) == 0) || (dirStyle.role == Preview && dir.loading && gOpts.dirpreviews) { if dirStyle.role != Preview || previewLoading { - win.print(screen, 2, 0, messageStyle, "loading...") + win.print(ui.screen, 2, 0, messageStyle, "loading...") } return } @@ -379,12 +379,12 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir break } - st = win.print(screen, 2, i, st, l) + st = win.print(ui.screen, 2, i, st, l) } return } if len(dir.files) == 0 { - win.print(screen, 2, 0, messageStyle, "empty") + win.print(ui.screen, 2, 0, messageStyle, "empty") return } @@ -428,18 +428,18 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir } } - win.print(screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln)) + win.print(ui.screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln)) } path := filepath.Join(dir.path, f.Name()) if _, ok := context.selections[path]; ok { - win.print(screen, lnwidth, i, st.Background(SelectionColor), " ") + win.print(ui.screen, lnwidth, i, st.Background(SelectionColor), " ") } else if cp, ok := context.saves[path]; ok { if cp { - win.print(screen, lnwidth, i, st.Background(YankColor), " ") + win.print(ui.screen, lnwidth, i, st.Background(YankColor), " ") } else { - win.print(screen, lnwidth, i, st.Background(CutColor), " ") + win.print(ui.screen, lnwidth, i, st.Background(CutColor), " ") } } @@ -486,7 +486,7 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir } ce := "" - if i == dir.pos { + if i == dir.pos && (ui.focused || !gOpts.hidecursorinactive) { switch dirStyle.role { case Active: ce = gOpts.cursoractivefmt @@ -500,14 +500,14 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir s = append(s, ' ') styledFilename := fmt.Sprintf(cursorescapefmt, string(s)) - win.print(screen, lnwidth+1, i, st, styledFilename) + win.print(ui.screen, lnwidth+1, i, st, styledFilename) tag, ok := context.tags[path] if ok { if i == dir.pos { - win.print(screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag)) + win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag)) } else { - win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)) + win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)) } } } @@ -562,6 +562,7 @@ type ui struct { screen tcell.Screen sxScreen sixelScreen polling bool + focused bool wins []*win promptWin *win msgWin *win @@ -592,6 +593,7 @@ func newUI(screen tcell.Screen) *ui { ui := &ui{ screen: screen, polling: true, + focused: true, wins: getWins(screen), promptWin: newWin(wtot, 1, 0, 0), msgWin: newWin(wtot, 1, 0, htot-1), @@ -1029,7 +1031,7 @@ func (ui *ui) draw(nav *nav) { role = Active } if dir := ui.dirOfWin(nav, i); dir != nil { - ui.wins[i].printDir(ui.screen, dir, &context, + ui.wins[i].printDir(ui, dir, &context, &dirStyle{colors: ui.styles, icons: ui.icons, role: role}, nav.previewLoading) } @@ -1060,7 +1062,7 @@ func (ui *ui) draw(nav *nav) { preview := ui.wins[len(ui.wins)-1] if curr.IsDir() { - preview.printDir(ui.screen, ui.dirPrev, &context, + preview.printDir(ui, ui.dirPrev, &context, &dirStyle{colors: ui.styles, icons: ui.icons, role: Preview}, nav.previewLoading) } else if curr.Mode().IsRegular() { @@ -1445,6 +1447,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr { log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When()) case *tcell.EventInterrupt: log.Printf("Got EventInterrupt: at %s", tev.When()) + case *tcell.EventFocus: + ui.focused = tev.Focused + return draw } return nil }