# Technical Documentation: gokcehan/lf

> ℹ️ **Provenance:** In-Tree Documentation (4 Chapters) · [CodeWiki Reference](https://codewiki.google/github.com/gokcehan/lf) · Recency: Active (< 180 days)

## File: README.md

# LF

[Doc](doc.md)
| [Wiki](https://github.com/gokcehan/lf/wiki)
| [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge)

[](https://github.com/gokcehan/lf/actions/workflows/go.yml)
[](https://goreportcard.com/report/github.com/gokcehan/lf)

`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from [`ranger`](https://github.com/ranger/ranger) file manager.
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.





## Features

- Cross-platform (Linux, macOS, BSDs, Windows)
- Single binary without any runtime dependencies
- Fast startup and low memory footprint due to native code and static binaries
- Asynchronous IO operations to avoid UI locking
- Server/client architecture and remote commands to manage multiple instances
- Extendable and configurable with shell commands
- Customizable keybindings (vi and readline defaults)
- A reasonable set of other features (see the [documentation](doc.md))

## Non-Features

- Tabs or windows (better handled by window manager or terminal multiplexer)
- Builtin pager/editor (better handled by your pager/editor of choice)
- Builtin commands for file operations (better handled by the underlying shell tools including but not limited to `mkdir`, `touch`, `chmod`, `chown`, `chgrp`, and `ln`)

## Installation

See [packages](https://github.com/gokcehan/lf/wiki/Packages) for community maintained packages.

See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.

Building from the source requires [Go](https://go.dev/).

On Unix:

```bash
env CGO_ENABLED=0 go install -trimpath -ldflags="-s -w" github.com/gokcehan/lf@latest
```

On Windows `cmd`:

```cmd
set CGO_ENABLED=0
go install -trimpath -ldflags="-s -w" github.com/gokcehan/lf@latest
```

On Windows `PowerShell`:

```powershell
$env:CGO_ENABLED = '0'
go install -trimpath -ldflags="-s -w" github.com/gokcehan/lf@latest
```

## Usage

After the installation `lf` command should start the application in the current directory.

Run `lf -help` to see [command line options](doc.md#options).

Run `lf -doc` to see the [documentation](doc.md).

See [etc](etc) directory to integrate `lf` to your shell and/or editor.
Example configuration files along with example colors and icons files can also be found in this directory.

See [integrations](https://github.com/gokcehan/lf/wiki/Integrations) to integrate `lf` to other tools.

See [tips](https://github.com/gokcehan/lf/wiki/Tips) for more examples.

## Contributing

See [contributing](CONTRIBUTING.md) for guidelines.

---

## File: CHANGELOG.md

# Changelog

All changes observable to end users should be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and should contain the following sections for each release:

- `Changed`
- `Added`
- `Fixed`

## Unreleased

### Added

- The `cd` command now supports `-` to change to the previous directory (#2693).

### Fixed

- Attempting to copy irregular files now results in an error instead of causing the copy operation to hang (#2618).
- Dead client connections no longer prevent the `quit` server command from terminating the server (#2643).
- The `calcdirsize` command now calculates the size of the target directory for symbolic links instead of the size of the link itself (#2650).
- Readline markers in `promptfmt` are no longer rendered as visible characters (#2657).
- Selecting entries with the mouse no longer causes the file list to jump unexpectedly (#2664).
- A bug where executing the `quit` command multiple times in quick succession could cause `lf` to become unresponsive is now fixed (#2674).
- The home directory abbreviation `~` no longer matches partial directory names (#2679).

## [r42](https://github.com/gokcehan/lf/releases/tag/r42)

### Changed

- The key `` has been renamed to `` for `map` keybindings (#2286).
- `.Stat.DirSize` and `.Stat.DirCount` in the ruler file no longer have a pointer type, and will be set to `-1` instead of `nil` if the corresponding value cannot be determined (#2397).
- `setlocal` commands no longer support the ability to specify recursive directories (#2415). For use cases where `setlocal` should apply to a directory based on some condition, it is recommended to script this inside the `on-load` hook command.
- On Windows, files are now considered executable according to `PATHEXT` when matching colors and icons (#2448).
- The `rulerfmt` and `statfmt` options are now marked as deprecated in favor of using the ruler file (configured using the `rulerfile` option), and will be removed in a future release (#2477).
- The client server connection will now exclusively use Unix domain sockets on Windows and no longer fall back to TCP sockets (#2527).
- The fallback location of the server socket (used if `XDG_RUNTIME_DIR` is not defined) is changed from `/tmp/lf..sock` to `/tmp/lf-/lf.sock`, and the containing directory must be owned by the current user (#2532).
- The `ignorecase` and `ignoredia` options (intended for searching) no longer affect sorting, and instead `sortignorecase` and `sortignoredia` have been added to customize sorting (#2543).
- Previews are now marked as binary if they contain a control character other than bell, backspace, tab, newline, vertical tab, form feed, carriage return, escape or delete (#2561). Previously only null bytes were used to detect binary previews.

### Added

- Emoji sequences containing Zero Width Joiner characters are now displayed as a single combined glyph (#2286).
- Key combinations such as `<c-h>` and `` can now be distinguished when supported by the terminal (#2286) (#2496).
- A new field `.All` is added to the `ruler` file to display the number of all files (i.e. visible + hidden) in the current working directory (#2376).
- A new option `numbercursorfmt` is added to further customize the appearance of line numbers (#2395).
- The `loading...` message delay of 100 milliseconds for file previews is now applied to directories as well (#2410).
- `lf` will now automatically change to the parent directory if the current directory no longer exists and the `watch` option is enabled (#2424).
- A new option `terminalcursor` is added to customize the appearance of the terminal cursor (#2441).
- A new option `borderstyle` is added to control whether `drawbox` draws an outline, separators, or both (#2445). This also replaces the existing `roundbox` option.

### Fixed

- Previews are now cleaned when changing to an empty directory (#2369).
- The `dircounts` indicator for errors is changed back to `!` instead of `?` (#2372).
- Previews are now correctly updated on `visual-change` (#2373).
- The `select` command can now select files immediately after creation as part of a script (#2377).
- The `on-load` hook command now ignores `.git` directories to reduce flicker and repeated `on-load` triggers (#2382).
- Preview messages like `empty` or `loading...` have their alignment improved (#2400).
- A bug where the `loading...` message was not displayed for volatile previews after the first time is now fixed (#2410).
- The `cmd-transpose` command now advances the cursor correctly after swapping characters (#2413).
- Symbolic links are no longer followed when changing directories (#2423).
- Using the `select` command with a blank string as the argument now properly raises an error instead of changing to the parent directory (#2429).
- The number of bytes read is now limited for previews that contain extremely long lines (#2458).
- Control characters are now stripped from previews to prevent dangerous terminal sequences from being processed if the default previewer is used (#2459).
- Various fixes have been made to sanitize input data and prevent terminal sequence injection (#2467) (#2540) (#2542) (#2546) (#2590) (#2603).
- Sixel images with the same height as the preview window are now displayed correctly when using `tmux` (#2474).
- A bug where previews were loaded according to the old dimensions of the preview window following a terminal resize is now fixed (#2491).
- Completion matches are now properly aligned if they contain terminal sequences (#2511).
- `load` commands are now processed when the `watch` option is enabled, which should fix various issues with refreshing updated files/directories (#2513).
- Parsing octal values in strings are now restricted to numbers between `0` and `255` (#2516).
- Color values are now validated (must be between `0` and `255`) when parsing terminal sequences (#2517).
- Directories are now refreshed properly after using the `cd` command (#2518).
- Successfully copied files are no longer deleted if their timestamps could not be preserved (#2519).
- Previews no longer flicker when the terminal height decreases (#2537).
- Symbolic linked directories are now updated properly when the `watch` option is enabled (#2550).
- Previews of modified files are now updated properly when the `preload` option is enabled (#2567).
- Previews of files other than the current file are now reloaded immediately after being modified when the `watch` option is enabled (#2594) (#2602) (#2648).
- The `loading...` message now shows for files that are reloading due to being modified (#2597).
- Attempting to copy a directory into itself will now result in an error (#2608) (#2623).
- The permissions of state files (i.e. `files`/`history`/`marks`/`tags`) is now changed to only be accessible by the owner (#2612).
- Broken symbolic links are no longer silently overwritten when moving files (#2619).
- Using the `copy` or `cut` command with a path containing newline characters now results in an error instead of silently omitting the path (#2620).

## [r41](https://github.com/gokcehan/lf/releases/tag/r41)

### Changed

- The `previewer` script no longer skips non-regular files (#2327).
- Line numbers now take up less space when both `number` and `relativenumber` are enabled (#2331).
- Changes have been made to ruler configuration (#2338):
  - The ruler file is no longer experimental.
  - The ruler file will be used by default unless `rulerfmt` (now a blank string by default) is specified.
  - The ruler file is no longer read from fixed locations like `~/.config/lf/ruler`, and instead the `rulerfile` option has been repurposed to specify the path of the ruler file.

### Added

- A new server command `list` is added to print the IDs of all currently connected clients (#2314).
- The `previewer` and `cleaner` scripts now have their `stderr` output logged (#2316).
- The `ruler` file now supports `.Stat.Extension`, `.Stat.AccessTime`, `.Stat.BirthTime`, `.Stat.ChangeTime` and `.Stat.CustomInfo` (#2329), as well as `.Stat.DirSize` and `.Stat.DirCount` (#2343).
- A new option `mergeindicators` is added to reduce the gap before filenames, by merging tag and selection indicators into a single column (#2330).

### Fixed

- A bug where sixel images fail to display when scrolling back and forth is now fixed (#2301).
- Newline characters are now ignored when drawing the ruler with the `ruler` file configured (#2319).
- A potential crash when using the `scroll-up`/`scroll-down` commands is now fixed (#2320).
- Case-insensitive command-line completions no longer cause user input to be displayed in lowercase (#2336).
- Calculation of window widths for the `ratios` option is now more accurate (#2347).

## [r40](https://github.com/gokcehan/lf/releases/tag/r40)

### Fixed

- Error messages from the server are no longer written to the terminal which causes the UI to break (#2290).
- A bug where file previews fail to load properly when scrolling quickly is now fixed (#2292).

## [r39](https://github.com/gokcehan/lf/releases/tag/r39)

### Changed

- File extensions are now shown for long filenames even if they are truncated (#2159).
- The history file will no longer contain a space between the prefix and the actual command (e.g. `:quit` instead of `: quit`) for each line (#2161). The command `sed -i -E 's/^(.) /\1/' ~/.local/share/lf/history` can be run to make an existing history file compatible with the new format.
- The `cmd-history-next` and `cmd-history-prev` commands will now select only matching entries if part of the command is typed beforehand (#2161). Consecutive duplicate entries will also be skipped for convenience.
- The string representation of commands shown when displaying keybindings is simplified (e.g. `cd ~` instead of `cd -- [~]`) (#2165).
- `yes-no-prompts` now use the same design everywhere (#2212).
- Logs generated by `-log ` now get appended to `` instead of overwriting it (#2215).
- The `showbinds` menu now hides the redundant `mode` column (#2226) (#2228) and omits already typed keys (#2249).
- The `setlocal` command no longer requires absolute paths (#2253).
- The string representation of file permissions now matches the traditional `Unix` format instead of the one used by `Go` (#2270).

### Added

- A new command `cmd-menu-discard` is added to allow exiting the completion menu with completions discarded (#2146).
- The `lf_mode` environment variable will now be set to `compmenu` if the completion menu is active (#2146).
- A `ruler` config file is added as an alternate method for customizing the ruler (#2186). This is intended to eventually replace the existing `rulerfmt`/`statfmt` options and must be enabled using the new `rulerfile` option. **This feature is currently experimental.**
- A new option `preload` is added to enable calling the `previewer` to generate previews in advance (#2206). **This feature is currently experimental.**
- `OSC 8` escape codes to render clickable hyperlinks are now supported (#2243).

### Fixed

- `shell-pipe` commands no longer wait for output if kept open after the command has finished running (#2155).
- Natural sorting now compares string lengths when dealing with equivalent numbers (e.g. `0` is ordered before `00`) (#2177).
- A bug where the copy progress indicator only displayed the first time a file was copied is now fixed (#2181).
- A bug where the `source` command does not show an error message upon failure is now fixed (#2189).
- The `addcustominfo` (#2198) and `setlocal` (#2254) (#2259) commands, as well as the `cleaner` and `previewer` options (#2211) now support filename completions.
- A bug where an empty `custom` info property would still take up space is now fixed (#2208).
- A bug where setting `drawbox` could lead to scrolling outside the view is now fixed (#2210) (#2218).
- The preview cache is now not cleared when setting `ratios` to its current value (#2218).
- Filtering is fixed when using special characters in the search pattern if the `filtermethod` is `text` (#2231).
- Custom commands that output messages (e.g. `cmd greet echo 'hello world'`) now display properly (#2245).
- Errors in config files are now displayed properly (#2246).

## [r38](https://github.com/gokcehan/lf/releases/tag/r38)

### Changed

- The deprecated `globfilter` and `globsearch` options are now removed (#2108).
- Sixel image support is now enabled by default, and the `sixel` option has been removed as it is no longer required (#2109).
- The `dircache` option has now been removed (#2110). This was previously used as a workaround to disable the directory cache since at the time changes to files were not detected reliably, but this is no longer the case.
- The experimental `locale` option has been removed in favor of the recommendation to use `addcustominfo`/`set sortby custom` for custom sorting (#2111).
- The existing `doc` command has been renamed to `help` so that it is more natural for users (#2125).
- Text previews are no longer displayed with a padding of two spaces by default (#2131). Instead, a custom padding can be added in the `previewer` script, for example by piping to `sed 's/^/  /'`.

### Added

- Sixel image previews can now display multiple images as well as text (#2109).
- A new option `sizeunits` is added to allow displaying file sizes in either binary or decimal units (#2118).
- `XDG_CONFIG_HOME` and `XDG_DATA_HOME` are now taken into account when looking up config/data files on Windows (#2119).
- Three new options `menufmt`, `menuheaderfmt`, and `menuselectfmt` are added to customize the appearance of the menu (#2123).

### Fixed

- Error messages are now cleared after running interactive commands such as `invert`/`unselect`/`tag-toggle` (#2117).
- The menu is now drawn over sixel images instead of being hidden behind it if they overlap (#2122).
- A bug which prevents the user from quitting when copying files with a size of 0 has been fixed (#2130).
- `lf -remote` should no longer busy wait and cause high CPU usage if its output is not being read (#2138).
- The parameter types for command line options shown by `lf -help` now match the synopsis in the documentation (#2153).

## [r37](https://github.com/gokcehan/lf/releases/tag/r37)

### Changed

- The default paths of files read by `lf` is changed on Windows, to separate configuration files from data files (#2051).
  - Configuration files (`lfrc`/`colors`/`icons`) are now stored in `%APPDATA%`, which can be overridden by `%LF_CONFIG_HOME%`.
  - Data files (`files`/`marks`/`tags`/`history`) are now stored in `%LOCALAPPDATA%`, which can be overridden by `%LF_DATA_HOME%`.
- The change for following symbolic links when tagging files from the previous release has been reverted (#2055). The previous change made it impossible to tag symbolic links separately from their targets, and also caused `lf` to run slowly in some cases.
- The existing `globfilter` and `globsearch` options are now deprecated in favor of the new `filtermethod` and `searchmethod` options, which support regex patterns (#2058).
  - `set globfilter true` should be replaced by `set filtermethod glob`.
  - `set globsearch true` should be replaced by `set searchmethod glob`.
- File sizes are now displayed using binary units (e.g. `1.0K` means 1024 bytes, not 1000 bytes) (#2062). The maximum width for displaying the file size has been increased from four to five characters.

### Added

- `dircounts` are now respected when sorting by size (#2025).
- The `info` and `sortby` options now support `btime` (file creation time) (#2042). This depends on support for file creation times from the underlying system.
- The selection in Visual mode now follows wrapping when `wrapscan`/`wrapscroll` is enabled (#2056).
- Input pasted from the terminal is now ignored while in Normal mode (#2059). This prevents pasted content from being treated as keybindings, which can result in dangerous unintended behavior.
- The Command-line mode completion now supports keywords for the `selmode` and `sortby` options (#2061), as well as the `info` and `preserve` options (#2071).
- Command line options are now exported as environment variables in the form `lf_flag_{flag}` (#2079).
- Support is added for terminal escape sequences that disable text styles (#2101).

### Fixed

- `dircounts` are now automatically populated after enabling it (#2049).
- A bug where directories are unsorted after reloading when `dircache` is disabled is now fixed (#2050).
- Filenames are now escaped when completing shell commands (#2071).
- A bug where completion menu entries are misaligned when containing fullwidth characters is now fixed (#2071).
- The `on-load` command now passes all files in the directory as arguments, not just files visible to the user (#2077).
- Failure to move files across different filesystems is now shown as an error instead of a success in the UI (#2085).
- Errors are now logged correctly when there are multiple errors during move/copy operations (#2089).
- The progress for copy operations is now displayed immediately in the UI, even if it takes time to calculate the total size of files to be copied (#2093).

## [r36](https://github.com/gokcehan/lf/releases/tag/r36)

### Changed

- Tagging symbolic links now affects the target instead of the symbolic link itself. This mimics the behavior in `ranger` (#1997).
- The experimental command `invert-below` has been removed in favor of the newly added support for Visual mode (#2021).

### Added

- A new placeholder `%P` representing the scroll percentage is added to the `rulerfmt` option (#1985).
- A new `on-load` hook command is added, which is triggered when files in a directory are loaded in `lf` (#2010).
- The `info` option now supports `custom`, allowing users to display custom information for each file (#2012). The custom information should be added by the user via the `addcustominfo` command. Sorting by the custom information is also supported (#2019).
- Support for `visual-mode` has now been added (#2021) (#2035). This includes the following changes:
  - A new command `visual` (default `V`) can be used to enter Visual mode.
  - A new command `visual-change` (default `o` in Visual mode) can be used to swap the positions of the cursor and anchor (start of the visual selection).
  - A new command `visual-accept` (default `V` in Visual mode) can be used to exit Visual mode, adding the visual selection to the selection list.
  - A new command `visual-discard` (default `<esc>` in Visual mode) can be used to exit Visual mode, without adding the visual selection to the selection list.
  - A new command `visual-unselect` can be used to exit Visual mode, removing the visual selection from the selection list.
  - The existing `map` command now adds keybindings for both Normal and Visual modes. Two new commands `nmap` and `vmap` are added which can be used to add keybindings for only Normal or Visual mode respectively.
  - Two new commands `nmaps` and `vmaps` are added to display the list of keybindings in Normal and Visual mode respectively. These, along with the existing `maps` and `cmaps` commands, now display an extra column indicating the mode for which the keybindings apply to.
  - A new option `visualfmt` is added to customize the appearance of the visual selection.
  - Two new placeholders `%m` and `%M` are added to `statfmt` to display the mode in the status line. Both will display `VISUAL` when in Visual mode, however in Normal mode `%m` will display as a blank string while `%M` will display `NORMAL`.
  - A new placeholder `%v` is added to `rulerfmt` which displays the number of files in the Visual selection. This is included in the default setting for `rulerfmt`.
  - The `lf_mode` environment variable will now be set to `visual` while in Visual mode.
  - The environment variable `$fv` is now exported to shell commands, which lists the files in the visual selection.
- A `CHANGELOG.md` file has been added to the repo (#2027). This will be updated to describe `Changed`, `Added` and `Fixed` functionality for each new release.

### Fixed

- Displaying sixel images now uses the screen locking API in Tcell, which reduces flickering in the UI (#1943).
- The `cmd-history` command is now ignored outside of Normal or Command-line mode, to prevent accidentally escaping out of other modes (#1971).
- A potential crash when using the `cmd-delete-word-back` command is fixed (#1976).
- The `preserve` option now applies to directories in addition to files when copying. This includes preserving `timestamps` (#1979) and `mode` (#1981).
- The `lfrc.ps1.example` example config file is updated to include PowerShell equivalents for the default commands and keybindings (#1989).
- Quoting for the `lf` environment variable is fixed for PowerShell users (#1990).
- `tempmarks` are no longer cleared after the `sync` command is called (#1996).
- The file stat information is no longer displayed during the execution of a `shell-pipe` command even if the file is updated (#2002).
- Directories are now reloaded properly if any component in the current path is renamed (#2005).
- Write updates for the log file are now ignored when `watch` is enabled. This helps to reduce notification spam and potential of infinite loops (#2015).
- Attempting to `cut`/`copy` files into a directory without execute permissions no longer causes `lf` to crash, and an error message will be displayed instead (#2024).

## [r35](https://github.com/gokcehan/lf/releases/tag/r35)

### Added

- Support is added for displaying underline styles (#1896).
- Support is added for displaying underline colors (#1933).
- A new subcommand `files` is added to the `query` server command to list the files in the current directory as displayed in `lf` (#1949).
- A new `tty-write` command is added for sending escape sequences to the terminal (#1961). **Writing directly to `/dev/tty` is not recommended as it not synchronized and can interfere with drawing the UI.**

### Fixed

- The `trash` command in `lfrc.example` now verifies if the trash directory exists before moving files there (#1918).
- `lf` should no longer crash if it fails to open the log file (#1937).
- Arrow keys are now handled properly when waiting for a key press after executing a `shell-wait` (`!`) command (#1956).
- The `previewer` script is now only invoked for the current directory (instead of all directories), when starting `lf` with `dirpreviews` enabled (#1958).

## [r34](https://github.com/gokcehan/lf/releases/tag/r34)

### Changed

- The `autoquit` option is now enabled by default (#1839).

### Added

- A new option `locale` is added to sort files based on the collation rules of the provided locale (#1818). **This feature is currently experimental.**
- A new `on-init` hook command is added to allow triggering custom actions when `lf` has finished initializing and connecting to the server (#1838).

### Fixed

- The background color now renders properly when displaying filenames (#1849).
- A bug where the `on-quit` hook command causes an infinite loop has been fixed (#1856).
- File sizes now display correctly after being copied when `watch` is enabled (#1881).
- Files are now automatically unselected when removed by an external process, when `watch` is enabled (#1901).

## [r33](https://github.com/gokcehan/lf/releases/tag/r33)

### Changed

- The `globsearch` option, which previously affected both searching and filtering, now affects only searching. A new `globfilter` option is introduced to enable globs when filtering, and acts independently from `globsearch` (#1650).
- The `hidecursorinactive` option is replaced by the `on-focus-gained` and `on-focus-lost` hook commands. These commands can be used to invoke custom behavior when the terminal gains or loses focus (#1763).
- The `ruler` option (deprecated in favor of `rulerfmt`) is now removed (#1766).
- Line numbers from the `number` and `relativenumber` options are displayed in the main window only, instead of all windows (#1789).

### Added

- Support for Unix domain sockets (for communicating with the `lf` server) is added for Windows (#1637).
- Color and icon configurations now support the `target` keyword for symbolic links (#1644).
- A new option `roundbox` is added to use rounded corners when `drawbox` is enabled (#1653).
- A new option `watch` is added to allow using filesystem notifications to detect and display changes to files. This is an alternative to the `period` option, which polls the filesystem periodically for changes (#1667).
- Icons can now be colored independently of the filename (#1674).
- The `info` option now supports `perm`, `user` and `group` to display the permissions, user and group respectively for each file (#1799).
- A new option `showbinds` is added to toggle whether the keybinding hints are shown when a keybinding is partially typed (#1815).

### Fixed

- Sorting by extension is fixed for hidden files (#1670).
- The `on-quit` hook command is now triggered when the terminal is closed (#1681).
- Previews no longer flicker when deleting files (#1691).
- Previews no longer flicker when directories are being reloaded (#1697).
- `lfcd.nu` now runs properly without raising errors (#1728).
- Image previews (composed of ASCII art) containing long lines should now display properly (#1737).
- The performance is improved when copying files (#1749).
- `lfcd.cmd` now handles directories with special characters (#1772).
- Icon colors are no longer clipped when displaying in Windows Terminal (#1777).
- The file stat info is now cleared when changing to an empty directory (#1808).
- Error messages are cleared when opening files (#1809).

## [r32](https://github.com/gokcehan/lf/releases/tag/r32)

### Changed

- The example script `etc/lfcd.cmd` is updated to use the `-print-last-dir` option instead of `-last-dir-path` (#1444). Similar changes have been made for `etc/lfcd.ps1` (#1491), `etc/lfcd.fish` (#1503), and `etc/lfcd.nu` (#1575).
- The documentation from `lf -doc` and the `doc` command is now generated from Markdown using `pandoc` (#1474).

### Added

- A new option `hidecursorinactive` is added to hide the cursor when the terminal is not focused (#965).
- A new special command `on-redraw` is added to be able to run a command when the screen is redrawn or when the terminal is resized (#1479).
- Options `cutfmt`, `copyfmt` and `selectfmt` are added to configure the indicator color for cut/copied/selected files respectively (#1540).
- `zsh` completion is added for the `lfcd` command (#1564).
- The file stat information now falls back to displaying user/group ID if looking up the user/group name fails (#1590).
- A new environment variable `lf_mode` is now exported to indicate which mode `lf` is currently running in (#1594).
- Default icons are added for Docker Compose files (#1626).

### Fixed

- Default value of `rulerfmt` option is now left-padded with spaces to visually separate it from the file stat information (#1437).
- Previews should now work for files containing lines with 65536 characters or more (#1447).
- Sixel previews should now work when using `lfcd` scripts (#1451).
- Colors and icons should now display properly for character device files (#1469).
- The selection file is now immediately synced to physical storage after writing to it (#1480).
- Timestamps are preserved when moving files across devices (#1482).
- Fix crash for `high` and `low` commands when `scrolloff` is set to a large value (#1504).
- Documentation is updated with various spelling and grammar fixes (#1518).
- Files beginning with a dot (e.g. `.gitignore`) are named correctly after `paste` if another file with the same name already exists (#1525).
- Prevent potential race condition when sorting directory contents (#1526).
- Signals are now handled properly even after receiving and ignoring `SIGINT` (#1549).
- The file stat information should now update properly after using the `cd` command to change to a directory for the first time (#1536).
- Previous error messages should now be cleared after a `mark-save`/`mark-remove` operation (#1544).
- Fix high CPU usage issue when viewing CryFS filesystems (#1607).
- Invalid entries in the `marks` and `tags` files now raise an error message instead of crashing (#1614).
- Startup time is improved on Windows (#1617).
- Sixel previews are now resized properly when the horizontal size of the preview window changes (#1629).
- The cut buffer is only cleared if the `paste` operation succeeds (#1652).
- The extension after `.` is ignored to set the cursor position when renaming a directory (#1664).
- The option `period` should not cause flickers in sixel previews anymore (#1666).

## [r31](https://github.com/gokcehan/lf/releases/tag/r31)

### Changed

- There has been some changes in the server protocol. Make sure to kill the old server process when you update to avoid errors (i.e. `lf -remote 'quit!'`).
- A new server command `query` is added to expose internal state to users (#1384). A new builtin command `cmds` is added to display the commands. The old builtin command `jumps` is now removed. The builtin commands `maps` and `cmaps` now use the new server command.
- Environment variable exporting for files and options are not performed anymore while previewing and cleaning to avoid various issues with race conditions (#1354). Cleaning program should now instead receive an additional sixth argument for the next file path to be previewed to allow comparisons with the previous file path. User options (i.e. `user_{option}`) are now exported whenever they are changed (#1418).
- Command outputs are now exclusively attached to `stderr` to allow printing the last directory or selection to `stdout` (#1399) (#1402). Two new command line options `-print-last-dir` and `-print-selection` are added to print the last directory and selection to `stdout`. The example script `etc/lfcd.sh` is updated to use `-print-last-dir` instead. Other `lfcd` scripts are also likely to be updated in the future to use the new method (patches are welcome).
- The option `ruler` is now deprecated in favor of its replacement `rulerfmt` (#1386). The new `rulerfmt` option is more capable (i.e. displays option values, supports colors and attributes, and supports optional fields) and more consistent with the rest of our options. See the documentation for more information.

### Added

- Modifier keys (i.e. control, shift, alt) with special keys (e.g. arrows, enter) are now supported for most combinations (#1248).
- A new option `borderfmt` is added to configure colors for pane borders (#1251).
- New `lf` specific environment variables, `LF_CONFIG_HOME` on Windows and `LF_CONFIG/DATA_HOME` on Unix, are now supported to set the configuration directory (#1253).
- Tilde (i.e. `~`) expansion is performed during completion to be able to use expanded tilde paths as command arguments (#1246).
- A new option `preserve` is added to preserve attributes (i.e. mode and timestamps) while copying (#1026).
- The file `etc/icons.example` is updated for nerd-fonts v3.0.0 (#1271).
- A new builtin command `clearmaps` is added to clear all default keybindings except for `read` (i.e. `:`) and `cmap` keybindings to be able to `:quit` (#1286).
- A new option `statfmt` is added to configure the status line at the bottom (#1288).
- A new option `truncatepct` is added to determine the location of truncation from the beginning in terms of percentage (#1029).
- A new option `dupfilefmt` is added to configure the names of duplicate files while copying (#1315).
- Shell scripts `etc/lf.nu` and `etc/lfcd.nu` are added to the repository to allow completion and directory change with Nushell (#1341).
- Sixels are now supported for previewing (#1211). A new option `sixel` is added to enable this behavior.
- A new configuration keyword `setlocal` is added to configure directory specific options (#1381).
- A new command line command `cmd-delete-word-back` (default `a-backspace` and `a-backspace2`) is added to use word boundaries when deleting a word backwards (#1409).

### Fixed

- Cursor positions in the directory should now be preserved after file operations that changes the directory (e.g. create or delete) (#1247).
- Option `reverse` should now respect to sort stability requirements (#1261).
- Backspace should not exit `filter` mode anymore (#1269).
- Truncated double width characters should not cause misalignment for the file information (#1272).
- Piping shell commands should not refresh the preview anymore (#1281).
- Cursor position should now update properly after a terminal resize (#1290).
- Directories should now be reloaded properly after a `delete` operation (#1292).
- Executable file completion should not add entries to the log file anymore (#1307).
- Blank input lines are now allowed in piping shell commands (#1308).
- Shell commands arguments on Windows should now be quoted properly to fix various issues (#1309).
- Reloading in a symlink directory should not follow the symlink anymore (#1327).
- Command `load` should not flicker image previews anymore (#1335).
- Asynchronous shell commands should now trigger `load` automatically when they are finished (#1345).
- Changing the value of `preview` option should now clear image previews (#1350).
- Cursor position in the status line at the bottom should now consider double width characters properly (#1348).
- Filenames should only be quoted for `cmd` on Windows to avoid quoting issues for PowerShell (#1371).
- Inaccessible files should now be included in the directory list and display their `lstat` errors in the status line at the bottom (#1382).
- Command line command `cmd-delete-word` should now add the deleted text to the yank buffer (#1409).

## [r30](https://github.com/gokcehan/lf/releases/tag/r30)

### Added

- A new builtin command `jumps` is added to display the jump list (#1233).
- A new possible field `filter` is added to `ruler` option to display the filter indicator (#1223).

### Fixed

- Broken mappings for `bottom` command due to recent changes are fixed (#1240).
- Selecting a file does not scroll to bottom anymore (#1222).
- Broken builds on some platforms due to recent changes are fixed (#1168).

## [r29](https://github.com/gokcehan/lf/releases/tag/r29)

### Changed

- Three new options `cursoractivefmt`, `cursorparentfmt` and `cursorpreviewfmt` have been added (#1086) (#1106). The default style for the preview cursor is changed to underline. You can revert back to the old style with `set cursorpreviewfmt "\033[7m"`.
- An alternative boolean option syntax `set option true/false` is added in addition to the previous syntax `set option/nooption` (#758). If you have `set option true` in your configuration, then there is no need for any changes as it was already working as expected accidentally. If you have `set option false` in your configuration, then previously it was enabling the option instead accidentally but now it is disabling the option as intended. Any other syntax including `set option on/off` are now considered errors and result in error messages. Boolean option toggling `set option!` remains unchanged with no new alternative syntax added.
- Cursor is now placed at the file extension by default in rename prompts (#1162).
- The environment variable `VISUAL` is checked before `EDITOR` for the default editor choice (#1197).

### Added

- Mouse wheel events with the Control modifier have been bound to scrolling by default (#1051).
- Option values for `tagfmt` and `errorfmt` have been simplified to be able to avoid the reset sequence (#1086).
- Two default command line bindings for `<down>` and `` have been added for `cmd-history-next` and `cmd-history-prev` respectively (#1112).
- A new command `invert-below` is added to invert all selections below the cursor (#1101). **This feature is currently experimental.**
- Two new commands `maps` and `cmaps` have been added to display the current list of bindings (#1146) (#1201).
- A new option `numberfmt` is added to customize line numbers (#1177).
- A new environment variable `lf_count` is now exported to use the count in shell commands (#1187).
- A new environment variable `lf` is now exported to be used as the executable path (#1176).
- An example `mkdir` binding is added to the example configuration (#1188).
- An example binding to show execution results is added to the example configuration (#1188).
- Commands `top` and `bottom` now accepts counts to move to a specific line (#1196).
- A new option `ruler` is added to customize the ruler information with a new addition for free disk space (#1168) (#1205).

### Fixed

- Example `lfcd` files have been made safer to be able to alias the commands as `lf` (#1049).
- Backspace should not exit from `rename:` mode anymore (#1060).
- Preview is now refreshed even if the selection does not change (#1074).
- Stale directory cache entry is now deleted during rename (#1138).
- File information is now updated properly after reloading (#1149).
- Window widths are now calculated properly when `drawbox` is enabled (#1150).
- Line number widths are now calculated properly when there are exactly 10 entries (#1151).
- Preview is not redrawn in async shell commands (#1164).
- A small delay is added before showing loading text in preview pane to avoid flickering (#1154).
- Hard-coded box drawing characters are replaced with Tcell constants to enable the fallback mechanism (#1170).
- Option `relativenumber` now shows zero in the current line (#1171).
- Completion is not stuck in an infinite loop anymore when a match is longer than the window width (#1183).
- Completion now inserts the longest match even if there is no word before the cursor (#1184).
- Command `doc` should now work even if `lf` is not in the `PATH` variable (#1176).
- Directory option changes should not crash the program anymore (#1204).
- Option `selmode` is now validated for the accepted values (#1206).

## [r28](https://github.com/gokcehan/lf/releases/tag/r28)

### Changed

- Extension matching for colors and icons are now case insensitive (#908).

### Added

- Three new commands `high`, `middle`, and `low` are added to move the current selection relative to the screen (#824).
- Backspace on empty prompt now switches to Normal mode (#836).
- A new `history` option is now added to be able to disable history (#866).
- A new special expansion `%S` spacer is added for `promptfmt` to be able to right align parts (#867).
- A new command-line command `cmd-menu-accept` is now added to accept the currently selected match (#934).
- Command-line commands should now be shown in completion for `map` and `cmap` (#934).
- Italic escape codes should now be working in previews (#936).
- Position and size information are now also passed to the `cleaner` script as arguments (#945).
- A new option `dirpreviews` is now added to also pass directories to the `previewer` script (#842).
- A new option `selmode` is now added to be able to limit the selection to the current directory (#849).
- User defined options with `user_` prefix are now supported (#865).
- Adding or removing `$`/`%`/`!`/`&` characters in `:` mode should now change the mode accordingly (#960).
- A new special command `on-select` is now added to be able to run a command after the selection changes (#864).
- Mouse support is extended to be able to click filenames for selection and opening (#963).
- Two new environment variables `lf_width` and `lf_height` are now exported for shell commands.

### Fixed

- Option `tagfmt` can now be changed properly.
- User name, group name, and link count should now be displayed as before where available (#829).
- Tagging files with colons in their names should now work as expected (#857).
- Some multibyte characters should now be handled properly for completion (#934).
- Menu completion for a file in a subdirectory should now be working properly (#934).
- File completion should now be escaped properly in menu completion (#934).
- First use of `cmd-menu-complete-back` should now select the last completion as expected (#934).
- Broken symlinks should now be working properly in completion (#934).
- Files with stat errors should now be skipped properly in completion (#934).
- Empty search with `incsearch` option should now be handled properly (#944).
- History position is now also reset when leaving the command line (#953).
- Mouse drag events are now ignored properly to avoid command repetition (#962).
- Environment variables `HOME` and `USER` should now be used as fallback for locations on some systems (#972).
- File information is now displayed in the status line at first launch when there are no errors in the configuration file (#994).

## [r27](https://github.com/gokcehan/lf/releases/tag/r27)

### Changed

- Creation of log files are now disabled by default. Instead, a new command line option `-log` is provided.
- `copy` selections are now kept after `paste` (#745). You can use `map p :paste; clear` to get the old behavior.
- The socket file is now created in `XDG_RUNTIME_DIR` when set, with a fallback to the temporary directory otherwise.
- Directory counting with `dircounts` option is moved from UI drawing to directory reading to be run asynchronously without locking the UI. With this change, manual `reload` commands might be necessary when `dircounts` is changed at runtime. Indicators for errors are changed to `!` instead of `?` to distinguish them from missing values.
- The default icons are now replaced with ASCII characters to avoid font issues.

### Added

- Files and options are now exported for `previewer` and `cleaner` scripts. For `cleaner` scripts, this can be used to detect if the file selection is changed or not (e.g. `$1 == $f`) and act accordingly (e.g. skip cleaning).
- A new `tempmarks` option is added to set some marks as temporary (#744).
- The pattern `*filename` is added for colors and icons.
- A new `calcdirsize` command is added to calculate directory sizes (#750).
- Two new options `infotimefmtnew` and `infotimefmtold` are added to configure the time format used in `info` (#751).
- Two new commands `jump-next` (default `]`) and `jump-prev` (default `[`) are added to navigate the jumplist (#755).
- Colors and icons file support is now added to be able to configure without environment variables. Example colors and icons files are added to the repository under `etc` directory. See the documentation for more information.
- For Windows, an example `open` command is now provided in the PowerShell example configuration (#765).
- Two new commands `scroll-up` (default `<c-y>`) and `scroll-down` (default `<c-e>`) are added to be able to scroll the file list without moving (#764).
- A new special command `on-quit` is added to be able to run a command before quitting.
- Two new commands `tag` and `tag-toggle` (default `t`) are now added to be able to tag files (#791).

### Fixed

- `Chmod` calls in the codebase are now removed to avoid TOC/TOU exploits. Instead, file permissions are now set at file creation.
- Socket and log files are now created with only user permissions.
- On Windows, `PWD` variable is now quoted properly.
- Shell commands `%` and `&` are now run in a separate process group (#753).
- Navigation initialization is now delayed after the evaluation of configuration files to avoid startup races and redundant loadings (#759).
- The error message shown when the current working directory does not exist at startup is made more clear.
- Trailing slashes in `PWD` variable are now handled properly.
- Files with `stat` errors are now skipped while reading directories.

## [r26](https://github.com/gokcehan/lf/releases/tag/r26)

### Fixed

- On Windows, input handling is properly resumed after shell commands.

## [r25](https://github.com/gokcehan/lf/releases/tag/r25)

### Added

- A new `dironly` option is added to only show directories and hide regular files (#669).
- A new `dircache` option is added to disable caching of directories (#673).
- Two new commands `filter` and `setfilter` is added along with a new option `incfilter` and a `promptfmt` expansion `%F` to implement directory filtering feature (#667).
- A new special command `pre-cd` is added to run a command before a directory is changed (#685).
- `cmap` command now accepts all expressions similar to `map` (#686).

### Fixed

- Marking a symlink directory should now save the symlink path instead of the target path (#659).
- A number of crashes have been fixed when the `hidden` option is changed.

## [r24](https://github.com/gokcehan/lf/releases/tag/r24)

### Fixed

- Data directory is automatically created before the selection file is written.
- An error is returned for remote commands when the given ID is not connected to the server.
- Prompts longer than the width should not crash the program anymore.

## [r23](https://github.com/gokcehan/lf/releases/tag/r23)

### Changed

- There has been some changes in the server protocol. Make sure to kill the old server process when you update to avoid errors.
- Server `load` and `save` commands are now removed. Instead a local file is used to record file selections (e.g. `~/.local/share/lf/files`). See the documentation for more information.
- Clients are now disconnected from server on quit. The old server `quit` command is renamed to `quit!` to act as a force quit by closing connected client connections first. A new `quit` command is added to only quit when there are no connected clients left.

### Added

- A new `autoquit` option is added to automatically quit the server when there are no connected clients left. This option is disabled by default to keep the old behavior. This is added as an option to avoid respawning server repeatedly when there is often a single client involved but more clients are spawned from time to time.
- A new `-single` command line flag is added to avoid spawning and/or connecting to server on startup. Remote commands would not work in this case as the client does not connect to a server. Local versions of internal `load` and `sync` commands are implemented properly.
- Errors for remote commands are now also shown in the output in addition to the server log file.
- Bright ANSI color escape codes (i.e. 90-97 and 100-107) are now supported.

### Fixed

- Lookahead size for escape codes are increased to recognize longer escape codes used in some image previewers.
- The file preview cache is invalidated when the terminal height changes to fill the screen properly.
- The file preview cache is invalidated when the `drawbox` option changes and true image previews should be triggered to be drawn at updated positions.
- A crash scenario is fixed when `hidden` option is changed.
- Pane widths should now be calculated properly when big numbers are used in `ratios` (#622).
- The special bookmark `'` is now preserved properly after `sync` commands (#624).
- On some platforms, a bug has been fixed on the Tcell side to avoid an extra key press after terminal suspend/resume and the Tcell version used in `lf` is bumped accordingly to include the fix.
- The prompt line should now scroll accordingly when the text is wider than the screen.
- Text width in the prompt line should now be calculated properly when non-ASCII characters are involved.
- Erase line escape codes (i.e. `\033[K`) used in some command outputs should now be ignored properly.

## [r22](https://github.com/gokcehan/lf/releases/tag/r22)

### Added

- A new `-config` command line flag is added to use a custom config file path (#587).
- The current working directory is now exported as `PWD` environment variable (#591). Subshells in symlink directories should now start in their own paths properly.
- The initial working directory is now exported as `OLDPWD` environment variable.
- A new `shellflag` option is added to customize the shell flag used for passing commands (i.e. default `-c` for Unix and `/c` for Windows).
- Using the command `cmd-enter` during `find` and `find-back` now jumps to the first match (#605).
- A new `waitmsg` option is added to customize the prompt message after `shell-wait` commands (i.e. default `Press any key to continue`) (#604).

### Fixed

- A regression bug is fixed to print a newline in the prompt message properly after `shell-wait` commands.
- A regression bug is fixed to avoid CPU stuck at 100% when the terminal is closed unexpectedly.
- A regression bug is fixed to make shell commands use the alternate screen properly and keep the terminal history after quitting.
- Enter keypad terminfo sequence is now sent on startup so the `delete` key should be recognized properly in `st` terminal.

## [r21](https://github.com/gokcehan/lf/releases/tag/r21)

### Changed

- `cut` and `copy` do not follow symlinks anymore. Broken symlinks can now be selected for the `cut` and `copy` commands (#581).

### Added

- User name, group name, and hard link counts are now shown in the status line at the bottom when available.
- Number of selected, copied, and cut files are now shown in the ruler at the bottom when they are non-zero.
- Hard-coded shell commands with `stty` (Unix) and `pause` (Windows) to implement the `Press any key to continue` behavior are now implemented properly with a Go terminal handling library. With this change, the requirement for a POSIX compatible shell for `shell` option is now dropped and other shells can be used.

### Fixed

- A longstanding issue regarding UI suspend/resume for shell commands in macOS is now fixed in Tcell.
- Renaming a symlink to its target or a symlink to another with the same target should now be handled properly (#581).
- Autocompletion in a directory containing a broken symlink should now work as intended (#581).
- Setting `shellopts` to empty in the configuration file should not pass an extra empty argument to shell commands anymore.
- Previously given tip to trap `SIGPIPE` in the preview script to enable caching is now updated in the documentation. Trapping the signal in the preview script avoids sending the signal to the program when enough lines are read. This may result in reading redundant lines especially for big files. The recommended method is now to add a trailing `|| true` to each command exiting with a non-zero return code after a `SIGPIPE`.

## [r20](https://github.com/gokcehan/lf/releases/tag/r20)

### Added

- A new `mouse` option is added to enable mouse events. This option is disabled by default to leave mouse events to the terminal. Also unbound mouse events when `mouse` is enabled should now show an `unknown mapping` error in the message line.

### Fixed

- Newline characters in the output of `%` commands should no longer shift the content up which was a bug introduced in the previous release due to a fix to handle combining characters in texts.
- Redundant preview loadings for the `search` and `find` commands are now avoided (#569).
- Scanner now only considers ASCII characters for spaces and digits which should avoid unexpected splits in some non-ASCII inputs.

## [r19](https://github.com/gokcehan/lf/releases/tag/r19)

### Changed

- Changes have been made to enable the use of true image previews. See the documentation and the previews wiki page for more information.
  - Non-zero exit codes should now make the preview volatile to avoid caching. Programs that may not behave well to `SIGPIPE` may trigger this behavior unintentionally. You may trap `SIGPIPE` in your preview script to get the old behavior.
  - Preview scripts should now get as arguments the current file path, width, height, horizontal position, and vertical position. Note that height is still passed as an argument but its order is changed.
  - A new `cleaner` option is added to set the path to a file to be executed when the preview is changed.
  - Redundant preview loadings for movement commands are now avoided.
- Expansion `%w` in `promptfmt` is changed back to its old behavior without a trailing separator. Instead, a new expansion `%d` is added with a trailing separator (#545). Expansion `%w` is meant to be used to display the current working directory, whereas `%d%f` is meant to be used to display the current file.
- A new `LF_COLORS` environment variable is now checked to be able to make `lf` specific configurations. Also, environment variables for colors are now read cumulatively starting from the default behavior (i.e. default, `LSCOLORS`, `LS_COLORS`, `LF_COLORS`).

### Added

- Full path, dir name, file name, and base name matching patterns are added to colors and icons. See the updated documentation for more information.
- PowerShell keybinding example has been added to `etc/lfcd.ps1` (#532).
- PowerShell autocompletion script has been added as `etc/lf.ps1` (#535).
- Multiple `-command` flags can now be given (#552).
- Basic mouse support has been added. Mouse buttons (e.g. `<m-1>` for primary button, `<m-2>` for secondary button, `<m-3>` for middle button etc.) and mouse wheels (e.g. `<m-up>` for wheel up, `<m-down>` for wheel down etc.) can be used in bindings.
- Commands `top` and `bottom` are now allowed in `cmap` mappings in addition to movement commands.

### Fixed

- Extension sorting should now handle extensions with different lengths properly (#539).
- Heuristic used to show `info` should now take into account the `number` and `icons` options properly.
- The environment variable `id` is now set to the process ID instead to avoid two clients getting the same ID when launched at the same time (#550).
- Unicode combining characters in texts should now be displayed properly.

## [r18](https://github.com/gokcehan/lf/releases/tag/r18)

### Changed

- The `ignorecase` and `ignoredia` options should now also apply to sorting in addition to searching.
- The `ignoredia` option is now enabled by default to be consistent with `ignorecase`.
- The terminal UI library Tcell has been updated to version 2. This version highlights adding 24-bit true colors on Windows and better support for colors on Unix. The environment variable `TCELL_TRUECOLOR` is not required anymore so that terminal themes and true colors can be used at the same time.
- The deprecated option `color256` is now removed.

### Added

- Two new command line commands `cmd-menu-complete` and `cmd-menu-complete-back` are added for completion menu cycling (#482).
- Simple configuration files for Windows `etc/lfrc.cmd.example` and `etc/lfrc.ps1.example` are now added to the repository.
- Bash completion script `etc/lf.bash` is now added to the repository.
- Time formats in `info` option should now show the year instead of `hh:mm` for times older than the current year.

### Fixed

- Signals `SIGHUP`, `SIGQUIT`, and `SIGTERM` should now quit the program properly.
- Setting `info` to an empty value should not print errors to the log file anymore.
- Natural sorting is optimized to work faster using less memory.
- Files and directories that incorrectly show modification times in the future (e.g. Linux builtin exFAT driver) should not cause CPU hogging anymore.
- The keybinding example in `etc/lfcd.fish` is now updated to avoid hanging in shell commands.
- Using the `bottom` command immediately after startup should not crash the program anymore.
- Changing sorting options during sorting operations should not crash the program anymore.
- Output in `shell-pipe` commands now uses lazy redrawing so that verbose commands should not block the program anymore.
- The server is now daemonized properly on Unix so that it is not killed anymore when the controlling terminal is killed (#517).

## [r17](https://github.com/gokcehan/lf/releases/tag/r17)

### Changed

- The terminal UI library has been changed from Termbox to Tcell as the former has been unmaintained for a while (#439). Some of the changes are listed below, though the list may not be complete as this is a relatively big change.
  - Some special key names are changed to be consistent with the Tcell documentation (e.g. `` renamed to ``). On the other hand, there are also additional keybindings that were not available before (e.g. `` for <kbd>Shift+Tab</kbd>). You can either check the Tcell documentation for the list of keys or hit the key combination in `lf` to read the name of the key from the `unknown mapping` error message.
  - 24-bit true colors are now supported on Unix systems. See the updated documentation for more information. There is an ongoing version 2.0 of Tcell in development that we plan to switch to once it becomes stable and it is expected to add support for true colors in Windows consoles as well.
  - Additional platforms are now supported and the list of pre-built binaries provided are updated accordingly.
  - Wide characters are now displayed properly in Windows consoles.

### Added

- Descriptions of commands and options are now added to the documentation. Undocumented behaviors should now be considered documentation bugs and they can be reported.
- Keys are now evaluated with a lazy drawing approach so `push` commands to set the prompt and pasting something to the command line should feel instantaneous.

### Fixed

- Corrupted history files should no longer crash the program.
- The server now only listens connections from `localhost` on Windows so firewall permissions are not required anymore.
- `push` commands that change the operation mode should now work consistently as expected.
- Loading directories should now display the previous file list if any, which was a regression due to a bug fix in a previous release.
- `shell-pipe` commands should now automatically update previews when necessary.
- Errors from failed shell commands should not be overwritten by file information anymore.
- The server can now also be started automatically when the program is called with a relative path, which was a regression due to a bug fix in a previous release (#463).
- Environment variables are now exported automatically for preview scripts without having to call a shell command first (#468).
- The `<esc>` key can now be bound to be used on its own, instead of escaping a keybinding combination, which was a regression due to a bug fix in a previous release (#475).
- Changing the `hiddenfiles` option should now automatically trigger directory updates when necessary.

## [r16](https://github.com/gokcehan/lf/releases/tag/r16)

### Added

- Option values are now available in shell commands as environment variables with a prefix of `lf_` (e.g. `$lf_hidden`, `$lf_ratios`) (#448).

### Fixed

- Directories containing internal Windows links that show permission denied errors should now display properly.

## [r15](https://github.com/gokcehan/lf/releases/tag/r15)

### Changed

- The `toggle` command does not move the selection down anymore. The default binding for `<space>` is now assigned to `:toggle; down` instead to keep the default behavior same as before.
- The expansion `%w` in option `promptfmt` should now have a trailing slash. The default value of `promptfmt` is now changed accordingly, and should not display double slashes in the root directory anymore.
- The key `<esc>` is now used as the escape key. It should not display an error message when used to cancel a keybinding menu as before. However, it is not possible to bind `<esc>` key to another command anymore.

### Added

- Symbolic link destinations are now shown in the bottom status line (#374).
- A new `hiddenfiles` option which takes a list of globs is implemented to customize which files should be `hidden` (#372).
- Expressions consisting of multiple commands can now use counts (#394).
- Moving operations now fall back to copy and then delete strategy automatically for cross-device linking.
- The `hidden` option now works in Windows.
- The `toggle` command can now take optional arguments to toggle given names instead of the current file (#409).
- A new option `truncatechar` is implemented to customize the truncate character used in long filenames (#417).
- Copy and move operations now display a success message when they are finished (#427).

### Fixed

- `SIGHUP` and `SIGTERM` signals are now properly handled. Log files should not remain when terminals are directly closed (#305).
- The `info` option should now align properly when used with the `number` and `relativenumber` options (#373).
- Tilde (`~`) is now only expanded at the beginning of the path for the `cd` and `select` commands (#373).
- The `rename` command should now work properly with names differing only cases on case-insensitive filesystems.
- Tab characters are now expanded to spaces in Windows.
- The `incsearch` option now respects the search direction accordingly.
- The server is now started in the home folder and will not hold mounted filesystems busy.
- Trailing spaces in configuration files do not confuse the parser anymore.
- Termbox version is updated to fix a keyboard problem in FreeBSD (#404).
- Async commands do not leave zombie processes anymore (#407).
- The `hidden` option now works consistently as expected when set at the initial launch.
- The `rename` command should now select the new file after the operation.
- The `rename` command should now handle absolute paths properly.
- The `select` command should now work properly on loading directories. Custom commands that select a file after an operation should now work properly without an explicit `load` operation beforehand.
- Previous errors in the bottom message line should not persist through the prompt usage anymore.
- The `push` command should not fail with non-ASCII characters anymore.
- The `select` command should not fail with broken links anymore.
- The `load` command should not clear toggled broken links anymore.
- Copy and move operations do not overwrite broken links anymore.

## [r14](https://github.com/gokcehan/lf/releases/tag/r14)

### Added

- The `delete` command now shows a prompt with the current filename or the number of selected files (#206).
- Backslash can now be escaped with a backslash even without quotes.
- A new desktop entry file `lf.desktop` is added (#222).
- Three new `sortby` types are added, access time (i.e. `atime`), change time (i.e. `ctime`) (#226), and extension (i.e. `ext`) (#230). New default keybindings are added for these sorts correspondingly (i.e. `sa`, `sc`, and `se`). The `info` option can now also contain `atime` and `ctime` values accordingly.
- A new shell completion for `zsh` is added to `etc/lf.zsh` (#239).
- The `delete` command now works asynchronously and shows the progress (#238).
- Completion and directory change scripts are added for `csh` and `tcsh` as `etc/lf.csh` and `etc/lfcd.csh` respectively (#264).
- A new special command `on-cd` is added to run a shell command when the directory is changed. See the documentation for more information (#291).

### Fixed

- Some directories with special permissions that previously show a file icon now shows a directory icon properly.
- The `etc/lfcd.cmd` script can now also change to a different volume drive (#221).
- The proper use of `setsid` for opening files is now added to the example configuration and the documentation.
- The home directory abbreviation `~` is now only applied properly to paths starting with the home directory (#241).
- The `rename` command now cancels the operation if the old and new paths are the same (#266).
- Autocompletion and word movements should now work properly with all Unicode characters.
- The `shell-pipe` command which was broken some time ago should now work as expected.
- The `$TERM` environment variable can now work with values containing `tmux` with custom `$TERMINFO` values. @doronbehar now maintains a Termbox fork for `lf` (https://github.com/doronbehar/termbox-go).

## [r13](https://github.com/gokcehan/lf/releases/tag/r13)

### Added

- A new `wrapscroll` option is added to wrap top and bottom while scrolling (#166).
- The `up`, `down` movement commands and their variants, `updir`, and `open` are now allowed in `cmap` mappings.
- Two new `glob-select` and `glob-unselect` commands are added to use globbing for toggling files (#184).
- A new `mark-remove` (default `"`) command is added to allow removing marks (#190).
- Icon support is added with the `icon` option. See the wiki page for more details.
- A new builtin `rename` command is added (#197).

### Fixed

- The `cmd-history-next` command now remains in Command-line mode after the last item (#168).
- The `select` command does not change directories anymore when used on a directory.
- The working directory is now changed to the first argument when it is a directory.
- The `ratios` option is now checked before `preview` to avoid crashes (#174).
- Previous error messages are now cleared after successful commands (#192).
- Symlink to directories are now colored as symlinks (#195).
- Permission errors for directories are now displayed properly instead of showing as empty (#203).

## [r12](https://github.com/gokcehan/lf/releases/tag/r12)

### Added

- Go modules replaced `godep` for dependency management. Package maintainers may need to update accordingly.
- A new `errorfmt` option is added to customize the colors and attributes of error messages.

### Fixed

- Autocompletion for searches now complete filenames instead of commands.
- Permanent environment variables (e.g. `$id`, `$EDITOR`, `$LF_LEVEL`) are now exported on startup so they can be used in preview scripts without running a shell command first.
- On Windows, quotes are added to the exported values `$f`, `$fs`, and `$fx` to handle filenames with spaces properly.
- On Windows, filenames starting with `.` characters are now shown to avoid crashes when filenames show up as empty.

## [r11](https://github.com/gokcehan/lf/releases/tag/r11)

### Changed

- Copy and move operations are now implemented as builtins instead of using the underlying shell primitives (i.e. `cp` and `mv`). Users who want the old behavior can define a custom `paste` command. See the updated documentation for more information. Please report bugs regarding this change.
- Preview messages (i.e. `empty`, `binary`, and `loading...`) are now shown with the reverse attribute.

### Added

- Copy and move operations now run asynchronously and the progress is shown in the bottom ruler.
- Two new commands `echomsg` and `echoerr` are added to print a message to the message line and to the log file at the same time.

### Fixed

- Terminal initialization errors are now shown in the terminal instead of the log file.

## [r10](https://github.com/gokcehan/lf/releases/tag/r10)

### Changed

- The ability to map Normal mode commands in `cmap` is removed. This has caused a number of bugs in the previous release. A different mechanism for a similar functionality is planned.

### Added

- A new command line flag `-command` has been added to execute a command on client initialization (#135).
- A `select` command is now executed after initialization if the first command line argument is a file.
- A prompting mechanism has been added to the builtin `delete` command.

### Fixed

- Input and output in `shell-pipe` commands were broken with the `cmap` patch. This should now work as before.
- Some `push` commands were broken with the `cmap` patch and sometimes ignored Command-line mode for some keys to execute as in Normal mode. This should now work as before.
- `read` and shell commands should now also work when typed manually (e.g. typing `:shell` should switch the prefix to `$`).
- Configuration files are now read after initialization.
- Background colors are removed from defaults to avoid confusion with selection highlighting.

## [r9](https://github.com/gokcehan/lf/releases/tag/r9)

### Changed

- The default number of colors is set to 8 to have better defaults in some terminals. A new option `color256` is added to use 256 colors instead. Users who want the old behavior should enable this option in their configuration files.

### Added

- A new `incsearch` option is added to enable incremental matching while searching.
- Two new options `ignoredia` and `smartdia` are added to ignore diacritics in Latin letters for `search` and `find` (#118).
- A new builtin `delete` command is added for file deletion (#121). This command is not assigned to a key by default to prevent accidental deletions. In the future, a prompting mechanism may be added to this command for more safety.
- Normal mode commands can now be used in `cmap` which can be used to immediately finish Command-line mode and execute a Normal mode command afterwards.
- A new `fish` completion script is added to the `etc` folder (#131).
- Two new options `number` and `relativenumber` are added to enable line numbers in directories (#133).

### Fixed

- Autocompletion should now show only a single match for redefined builtin commands.

## [r8](https://github.com/gokcehan/lf/releases/tag/r8)

### Added

- Four new commands `find`, `find-back`, `find-next`, and `find-prev` are added to implement file finding. Two options `anchorfind` and `findlen` are added to customize the behavior of these commands.
- A new `quit` command is added to the server protocol to quit the server.
- A new `$LF_LEVEL` environment variable is added to show the nesting level.

### Fixed

- The `load` and `reload` commands now work properly when the current directory is deleted. Also `lf` does not start in deleted directories anymore.
- The server is now started as a detached process in Windows so its lifetime is not tied to the command line window anymore.
- Clients now try to reconnect to the server at startup with exponentially increasing intervals when they fail. This is to avoid connection failures due to the server not being ready for the first client that automatically starts the server.
- The old index is now kept when the current selection is deleted.
- The `shell-pipe` command now triggers `load` instead of `reload`.
- Error messages are now more informative when `lf` fails to start due to either `$HOME` or `$USER` variables being empty or not set.
- Searching for the next/previous item is now based on the direction of the initial search.

## [r7](https://github.com/gokcehan/lf/releases/tag/r7)

### Changed

- The system-wide configuration path on Unix is changed from `/etc/lfrc` to `/etc/lf/lfrc`.

### Added

- A man page is now automatically generated from the documentation which can be installed to make the documentation available with the `man` command. On a related note, there is now a packaging guide section in packages wiki page.
- A new `doc` command (default `<f-1>`) is added to view the documentation in a pager.
- Commands `mark-save` (default `m`) and `mark-load` (default `'`) are added to implement builtin bookmarks. Marks are saved in a file in the data folder which can be found in the documentation.
- The history is now saved in a file in the data folder which can be found in the documentation.

## [r6](https://github.com/gokcehan/lf/releases/tag/r6)

### Changed

- The `yank`, `delete`, and `put` commands are renamed to `copy`, `cut`, and `paste` respectively. In the example configuration, the `remove` command is renamed to `delete`.
- The special command `open-file` to configure file opening is renamed to `open`.

### Added

- A new option `shellopts` is added to be able to pass command line arguments to the shell interpreter (i.e. `<shell> <shellopts> -c <cmd> -- <args>`) which is useful to set safety options for all shell commands (i.e. `sh -eu ...`). See the example configuration file for more information.
- The special keys `<home>`, `<end>`, ``, and `` are mapped to the `top`, `bottom`, `page-up`, and `page-down` commands respectively by default.
- A new command `source` is added to read a configuration file.
- Support is added to read a system-wide configuration file on startup located in `/etc/lfrc` on Unix and `C:\ProgramData\lf\lfrc` on Windows. The documentation is updated to show the locations of all configuration files.
- Environment variables used for configuration (i.e. `$EDITOR`, `$PAGER`, `$SHELL`) are set to their default values when they are not set or empty and they are exported to shell commands.
- A new environment variable `$OPENER` is added to configure the default file opener using the previous default values and it is exported to shell commands.

### Fixed

- Executable completion now works on Windows as well.

## [r5](https://github.com/gokcehan/lf/releases/tag/r5)

### Added

- The server is automatically restarted on startup if it does not work anymore.
- A new option `period` is added to set time duration in seconds for periodic refreshes. Setting the value of this option to zero disables periodic refreshes which is the default behavior.
- A new command `load` is added to refresh only modified files and directories which is more efficient than `reload` command.

### Fixed

- `cmd-word-back` does not change the command line anymore.
- Modified files and directories are automatically detected and refreshed when they are loaded from cache.
- All clients are now refreshed when the `put` command is used.
- The correct hidden parent is selected when the `hidden` option is changed.
- The preview is properly updated when the `hidden` option is changed.

## [r4](https://github.com/gokcehan/lf/releases/tag/r4)

### Changed

- The following commands are renamed for clarity and consistency:
  - `bot` is renamed to `bottom`
  - `cmd-delete-word` is renamed to `cmd-delete-unix-word`
  - `cmd-beg` is renamed to `cmd-home`
  - `cmd-delete-beg` is renamed to `cmd-delete-home`
  - `cmd-comp` is renamed to `cmd-complete`
  - `cmd-hist-next` is renamed to `cmd-history-next`
  - `cmd-hist-prev` is renamed to `cmd-history-prev`
  - `cmd-put` is renamed to `cmd-yank`

### Added

- Support for alt key bindings have been added using the commonly used escape delaying mechanism. The delay value is set to 100ms which is also used for other escape codes in Termbox. Keys are named with an `a` prefix, as in `<a-f>` for the `alt` and `f` keys. Also note that the old mechanism for alt keybindings on 8-bit terminals still works as before.
- The following command line commands and their default alt keybindings have been added:
  - `cmd-word` with `<a-f>`
  - `cmd-word-back` with `<a-b>`
  - `cmd-capitalize-word` with `<a-c>`
  - `cmd-delete-word` with `<a-d>`
  - `cmd-uppercase-word` with `<a-u>`
  - `cmd-lowercase-word` with `<a-l>`
  - `cmd-transpose-word` with `<a-t>`

### Fixed

- The default editor, pager, and opener commands should now work in Windows. Opener still only works with paths without spaces though.
- 8-bit color codes and attributes are not confused anymore.
- History selection is disabled when a `shell-pipe` command is running.
- Searches are now excluded from the history.

## [r3](https://github.com/gokcehan/lf/releases/tag/r3)

### Changed

- Command counts are now only applied for the `up`/`down` (and variants), `updir`, `toggle`, `search-next`, and `search-prev` commands. These commands are now handled more efficiently when used with counts.

### Added

- Pressed keys are now shown in the ruler when they are not matched yet.
- A new builtin `draw` command has been added which is more efficient than the `redraw` command. The latter is replaced with the former in many places to prevent flickers on the screen.
- Support for the `$LS_COLORS` and `$LSCOLORS` environment variables are added for color customization (#96). See the updated documentation for more information.
- A new option `drawbox` is added to draw a box around panes.

### Fixed

- Resize events that change the height are now handled properly.
- Changes in sorting methods and options are checked for cached directories and these directories are sorted again if necessary while loading.
- A `~` character is added as a suffix to file names when they do not fit in the window.

## [r2](https://github.com/gokcehan/lf/releases/tag/r2)

### Changed

- Shell command names are shortened (e.g. `read-shell-wait` is renamed to `shell-wait`).

### Added

- A new shell command type named `shell-pipe` is introduced that runs with the UI. See the updated documentation for the motivation and some example use cases.
- A new command named `cmd-interrupt` (default `<c-c>`) is introduced to interrupt the current `shell-pipe` command.
- A new command named `select` is introduced that changes the current file selection to its argument.

### Fixed

- Running `cmd-hist-prev` in Normal mode now always starts with the last item to avoid confusion. Running `cmd-hist-next` in Normal mode now has no effect for consistency.

## [r1](https://github.com/gokcehan/lf/releases/tag/r1)

### Added

- Initial release

---

## File: CONTRIBUTING.md

# Contributing

Code contributions are always welcome in `lf`.

If you are going to introduce a new feature, it is best to open an issue first for discussion. You should also consider the following:

- Whether it can be implemented entirely in user configuration instead
- The complexity added by supporting it
- The number of users interested in it

If your feature can be implemented as a configuration option, **please add it to the [wiki](https://github.com/gokcehan/lf/wiki)**.

For bug fixes, you can simply send a pull request.

## Code conventions

In addition to `gofmt` and friends (e.g. [go vet](https://pkg.go.dev/cmd/vet), [staticcheck](https://staticcheck.dev/), [golangci-lint](https://golangci-lint.run/)), we have a few conventions:

- Global variables are best avoided except when they are not.
  Global variable names are prefixed with `g` as in `gFooBar`.
  Exceptions are variables that store values of environment variables, which are prefixed with `env` as in `envFooBar`, and regular expressions, which are prefixed with `re` as in `reFooBar` when they are global.
- Type and function names are lowercase as in `fooBar` since we don't use exporting.
- For filename variables, `name`, `fname`, or `filename` should refer to the base name of the file as in `baz.txt`, and `path`, `fpath`, or `filepath` should refer to the full path of the file as in `/foo/bar/baz.txt`.
- Run `go fmt` to ensure that files are formatted correctly.
- Consider using [conventional](https://www.conventionalcommits.org/) commit messages.

Use the surrounding code as reference when in doubt as usual.

## Adding a new option

Adding a new option usually requires the following steps:

- Add option name/type to `gOpts` struct in `opts.go`
- Add default option value to `init` function in `opts.go`
- Add option evaluation logic to `setExpr.eval` in `eval.go`
- Implement the option somewhere in the code
- Add option name and its default value to `Quick Reference` and `Settings` sections in `doc.md`
- Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
- Commit your changes and send a pull request

Options should be defined in alphabetical order, but note that boolean options are defined first in `eval.go` as they require special handling.

## Adding a new builtin command

Adding a new command usually requires the following steps:

- Add default key if any to `init` function in `opts.go`
- Add command evaluation logic to `callExpr.eval` in `eval.go`
- Implement the command somewhere in the code
- Add command name to `gCmdWords` in `complete.go` for tab completion
- Add command name to `Quick Reference` and `Commands` sections in `doc.md`
- Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
- Commit your changes and send a pull request

Commands should be defined in alphabetical order, but note that commands are first organized roughly into the following sections in `eval.go` for clarity:

- Navigation
- Selection
- File-related operations
- Shell commands
- Finding and searching
- Filtering
- Marks
- Tags
- Echoing
- Miscellaneous commands
- Visual mode
- Command-line mode commands
- Hook commands

## Platform specific code

There are two files named `os.go` and `os_windows.go` for Unix and Windows specific code respectively.
If you add something to either of these files but not the other, you will probably break the build for the other platform.
If your addition works the same on both platforms, your addition probably belongs to `main.go` instead.

There are also different variants of the `df` functionality provided by `df_openbsd.go`, `df_statfs.go`, `df_statvfs.go` and `df_windows.go`.
Where applicable, ensure that any changes you make are reflected across all of these files for consistency.

---

## File: doc.md

# NAME

lf - terminal file manager

# SYNOPSIS

**lf**
[**-command** *command*]
[**-config** *path*]
[**-cpuprofile** *path*]
[**-doc**]
[**-help**]
[**-last-dir-path** *path*]
[**-log** *path*]
[**-memprofile** *path*]
[**-print-last-dir**]
[**-print-selection**]
[**-remote** *command*]
[**-selection-path** *path*]
[**-server**]
[**-single**]
[**-version**]
[*path*]

# DESCRIPTION

lf is a terminal file manager.

The source code can be found in the repository at https://github.com/gokcehan/lf

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 the `help` command (default `<f-1>`) 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

# OPTIONS

## POSITIONAL ARGUMENTS

**path**

Set the starting location. If *path* is a directory, start in there. If it's a file, start in the file's parent directory and select the file. When no *path* is supplied, lf uses the current directory. Only accepts one argument.

## META OPTIONS

**-doc**

Show lf's documentation (same content as this file) and exit.

**-help**

Show command-line usage and exit.

**-version**

Show version information and exit.

## STARTUP & CONFIGURATION

**-command** *command*

Execute *command* during client initialization (i.e. after reading configuration, before `on-init`). To execute more than one command, you can either use the **-command** flag multiple times or pass multiple commands at once by chaining them with ";".

**-config** *path*

Use the config file at *path* instead of the normal search locations. This only affects which `lfrc` is read at startup.

## SHELL INTEGRATION

**-print-last-dir**

Print the last directory to stdout when lf exits. This can be used to let lf change your shell's working directory. See `CHANGING DIRECTORY` for more details.

**-last-dir-path** *path*

Same as **-print-last-dir**, but write the directory to *path* instead of stdout.

**-print-selection**

Print selected files to stdout when opening a file in lf. This can be used to use lf as an "open file" dialog. First, select the files you want to pass to another program. Then, confirm the selection by opening a file. This causes lf to quit and print out the selection. Quitting lf prematurely discards the selection.

**-selection-path** *path*

Same as **-print-selection**, but write the newline-separated list to *path* instead of stdout.

## SERVER

**-remote** *command*

Send *command* to the running server (i.e. `send`, `query`, `list`, `quit`, or `quit!`). See `REMOTE COMMANDS` for more details.

**-server**

Start the (headless) server process explicitly. Runs in the foreground and writes server logs to stderr (or the file set with **-log**). Clients auto-start a server if none is running unless **-single** is used.

**-single**

Start a stand-alone client without a server. Disables remote control.

## DIAGNOSTICS

**-log** *path*

Append runtime log messages to *path*.

**-cpuprofile** *path*

Write a CPU profile to *path*. The profile can be used by `go tool pprof`.

**-memprofile** *path*

Write a memory profile to *path*. The profile can be used by `go tool pprof`.

## EXAMPLES

Use `lf` to select files (while hiding certain file types):

	lf -command 'set nohidden' -command 'set hiddenfiles "*mp4:*pdf:*txt"' -print-selection

Another sophisticated "open file" dialog focusing on design:

	lf -command 'set nopreview; set ratios 1; set drawbox; set promptfmt "Select files [%w] %S q: cancel, l: confirm"' -print-selection

Open Downloads and set `sortby` and `info` to creation date:

	lf -command 'set sortby btime; set info btime' ~/Downloads

Temporarily prevent `lf` from modifying the command history:

	lf -command 'set nohistory'

Use default settings and log current session:

	lf -config /dev/null -log /tmp/lf.log

Force-quit the server:

	lf -remote 'quit!'

Inherit lf's working directory in your shell:

	cd "$(lf -print-last-dir)"

# QUICK REFERENCE

The following commands are provided by lf:

	quit                     (default 'q')
	up                       (default 'k' and '')
	half-up                  (default '<c-u>')
	page-up                  (default '<c-b>' and '')
	scroll-up                (default '<c-y>')
	down                     (default 'j' and '<down>')
	half-down                (default '<c-d>')
	page-down                (default '<c-f>' and '')
	scroll-down              (default '<c-e>')
	updir                    (default 'h' and '<left>')
	open                     (default 'l' and '<right>')
	jump-next                (default ']')
	jump-prev                (default '[')
	top                      (default 'gg' and '<home>')
	bottom                   (default 'G' and '<end>')
	high                     (default 'H')
	middle                   (default 'M')
	low                      (default 'L')
	toggle
	invert                   (default 'v')
	unselect                 (default 'u')
	glob-select
	glob-unselect
	copy                     (default 'y')
	cut                      (default 'd')
	paste                    (default 'p')
	clear                    (default 'c')
	sync
	draw
	redraw                   (default '<c-l>')
	load
	reload                   (default '<c-r>')
	delete         (modal)
	rename         (modal)   (default 'r')
	read           (modal)   (default ':')
	shell          (modal)   (default '$')
	shell-pipe     (modal)   (default '%')
	shell-wait     (modal)   (default '!')
	shell-async    (modal)   (default '&')
	find           (modal)   (default 'f')
	find-back      (modal)   (default 'F')
	find-next                (default ';')
	find-prev                (default ',')
	search         (modal)   (default '/')
	search-back    (modal)   (default '?')
	search-next              (default 'n')
	search-prev              (default 'N')
	filter         (modal)
	setfilter
	mark-save      (modal)   (default 'm')
	mark-load      (modal)   (default "'")
	mark-remove    (modal)   (default '"')
	tag
	tag-toggle               (default 't')
	echo
	echomsg
	echoerr
	cd
	select
	source
	push
	addcustominfo
	calcdirsize
	clearmaps
	tty-write
	visual                   (default 'V')

The following Visual mode commands are provided by lf:

	visual-accept            (default 'V')
	visual-unselect
	visual-discard           (default '<esc>')
	visual-change            (default 'o')

The following Command-line mode commands are provided by lf:

	cmd-insert
	cmd-escape               (default '<esc>')
	cmd-complete             (default '<tab>')
	cmd-menu-complete
	cmd-menu-complete-back
	cmd-menu-accept
	cmd-menu-discard
	cmd-enter                (default '<c-j>' and '<enter>')
	cmd-interrupt            (default '<c-c>')
	cmd-history-next         (default '<c-n>' and '<down>')
	cmd-history-prev         (default '<c-p>' and '')
	cmd-left                 (default '<c-b>' and '<left>')
	cmd-right                (default '<c-f>' and '<right>')
	cmd-home                 (default '<c-a>' and '<home>')
	cmd-end                  (default '<c-e>' and '<end>')
	cmd-delete               (default '<c-d>' and '<delete>')
	cmd-delete-back          (default '')
	cmd-delete-home          (default '<c-u>')
	cmd-delete-end           (default '<c-k>')
	cmd-delete-unix-word     (default '<c-w>')
	cmd-yank                 (default '<c-y>')
	cmd-transpose            (default '<c-t>')
	cmd-transpose-word       (default '<a-t>')
	cmd-word                 (default '<a-f>')
	cmd-word-back            (default '<a-b>')
	cmd-delete-word          (default '<a-d>')
	cmd-delete-word-back     (default '<a-backspace>')
	cmd-capitalize-word      (default '<a-c>')
	cmd-uppercase-word       (default '<a-u>')
	cmd-lowercase-word       (default '<a-l>')

The following options can be used to customize the behavior of lf:

	anchorfind        bool      (default true)
	autoquit          bool      (default true)
	borderfmt         string    (default "\033[0m")
	borderstyle       string    (default 'box')
	cleaner           string    (default '')
	copyfmt           string    (default "\033[7;33m")
	cursoractivefmt   string    (default "\033[7m")
	cursorparentfmt   string    (default "\033[7m")
	cursorpreviewfmt  string    (default "\033[4m")
	cutfmt            string    (default "\033[7;31m")
	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")
	filtermethod      string    (default 'text')
	findlen           int       (default 1)
	hidden            bool      (default false)
	hiddenfiles       []string  (default '.*' for Unix and '' for Windows)
	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')
	menufmt           string    (default "\033[0m")
	menuheaderfmt     string    (default "\033[1m")
	menuselectfmt     string    (default "\033[7m")
	mergeindicators   bool      (default false)
	mouse             bool      (default false)
	number            bool      (default false)
	numbercursorfmt   string    (default '')
	numberfmt         string    (default "\033[33m")
	period            int       (default 0)
	preload           bool      (default false)
	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)
	rulerfile         string    (default "")
	rulerfmt          string    (default "")
	scrolloff         int       (default 0)
	searchmethod      string    (default 'text')
	selectfmt         string    (default "\033[7;35m")
	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 '')
	showbinds         bool      (default true)
	sizeunits         string    (default 'binary')
	smartcase         bool      (default true)
	smartdia          bool      (default false)
	sortby            string    (default 'natural')
	sortignorecase    bool      (default true)
	sortignoredia     bool      (default true)
	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 '')
	terminalcursor    string    (default 'default')
	timefmt           string    (default 'Mon Jan _2 15:04:05 2006')
	truncatechar      string    (default '~')
	truncatepct       int       (default 100)
	visualfmt         string    (default "\033[7;36m")
	waitmsg           string    (default 'Press any key to continue')
	watch             bool      (default false)
	wrapscan          bool      (default true)
	wrapscroll        bool      (default false)
	user_{option}     string    (default none)

The following environment variables are exported for shell commands:

	f
	fs
	fv
	fx
	id
	PWD
	OLDPWD
	LF_LEVEL
	OPENER
	VISUAL
	EDITOR
	PAGER
	SHELL
	lf
	lf_{option}
	lf_user_{option}
	lf_flag_{flag}
	lf_width
	lf_height
	lf_count
	lf_mode

The following special shell commands are used to customize the behavior of lf when defined:

	open
	paste
	rename
	delete
	pre-cd
	on-cd
	on-load
	on-focus-gained
	on-focus-lost
	on-init
	on-select
	on-redraw
	on-quit

The following commands/keybindings are provided by default:

	Unix
	cmd open &$OPENER "$f"
	map e $$EDITOR "$f"
	map i $$PAGER "$f"
	map w $$SHELL
	cmd help $$lf -doc | $PAGER
	map <f-1> help
	cmd maps $lf -remote "query $id maps" | $PAGER
	cmd nmaps $lf -remote "query $id nmaps" | $PAGER
	cmd vmaps $lf -remote "query $id vmaps" | $PAGER
	cmd cmaps $lf -remote "query $id cmaps" | $PAGER
	cmd cmds $lf -remote "query $id cmds" | $PAGER

	Windows
	cmd open &%OPENER% %f%
	map e $%EDITOR% %f%
	map i !%PAGER% %f%
	map w $%SHELL%
	cmd help !%lf% -doc | %PAGER%
	map <f-1> help
	cmd maps !%lf% -remote "query %id% maps" | %PAGER%
	cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
	cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
	cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
	cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%

The defaults for Windows are using `cmd` syntax.
A `PowerShell` compatible configuration file can be found at
https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example

The following additional keybindings are provided by default:

	map zh set hidden!
	map zr set reverse!
	map zn set info
	map zs set info size
	map zt set info time
	map za set info size:time
	map sn :set sortby natural; set info
	map ss :set sortby size; set info size
	map st :set sortby time; set info time
	map sa :set sortby atime; set info atime
	map sb :set sortby btime; set info btime
	map sc :set sortby ctime; set info ctime
	map se :set sortby ext; set info
	map gh cd ~
	nmap <space> :toggle; down

If the `mouse` option is enabled, mouse buttons have the following default effects:

	Left mouse button
	    Click on a file or directory to select it.

	Right mouse button
	    Enter a directory or open a file. Also works on the preview pane.

	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\Roaming\lf\lfrc

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\Roaming\lf\colors

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\Roaming\lf\icons

The selection file should be located at:

	Unix     ~/.local/share/lf/files
	Windows  C:\Users\\AppData\Local\lf\files

The marks file should be located at:

	Unix     ~/.local/share/lf/marks
	Windows  C:\Users\\AppData\Local\lf\marks

The tags file should be located at:

	Unix     ~/.local/share/lf/tags
	Windows  C:\Users\\AppData\Local\lf\tags

The history file should be located at:

	Unix     ~/.local/share/lf/history
	Windows  C:\Users\\AppData\Local\lf\history

You can configure these locations with the following variables given with their order of precedences and their default values:

	Unix
	    $LF_CONFIG_HOME
	    $XDG_CONFIG_HOME
	    ~/.config

	    $LF_DATA_HOME
	    $XDG_DATA_HOME
	    ~/.local/share

	Windows
	    %LF_CONFIG_HOME%
	    %XDG_CONFIG_HOME%
	    %APPDATA%

	    %LF_DATA_HOME%
	    %XDG_DATA_HOME%
	    %LOCALAPPDATA%

A sample configuration file can be found at
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example

# 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.

## quit (default `q`)

Quit lf and return to the shell.

## up (default `k` and ``), half-up (default `<c-u>`), page-up (default `<c-b>` and ``), scroll-up (default `<c-y>`), down (default `j` and `<down>`), half-down (default `<c-d>`), page-down (default `<c-f>` and ``), scroll-down (default `<c-e>`)

Move/scroll the current file selection upwards/downwards by one/half a page/full page.

## updir (default `h` and `<left>`)

Change the current working directory to the parent directory.

## open (default `l` and `<right>`)

If the current file is a directory, then change the current directory to it, otherwise, execute the `open` command.
A default `open` command is provided to call the default system opener asynchronously with the current file as the argument.
A custom `open` command can be defined to override this default.

## jump-next (default `]`), jump-prev (default `[`)

Change the current working directory to the next/previous jumplist item.

## top (default `gg` and `<home>`), bottom (default `G` and `<end>`)

Move the current file selection to the top/bottom of the directory.
A count can be specified to move to a specific line, for example, use `3G` to move to the third line.

## high (default `H`), middle (default `M`), low (default `L`)

Move the current file selection to the high/middle/low of the screen.

## toggle

Toggle the selection of the current file or files given as arguments.

## invert (default `v`)

Reverse the selection of all files in the current directory (i.e. `toggle` all files).
Selections in other directories are not 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.

## unselect (default `u`)

Remove the selection of all files in all directories.

## glob-select, glob-unselect

Select/unselect files that match the given glob.

## copy (default `y`)

Save the paths of selected files to the clipboard as files to be copied.
If there are no selected files, the path of the current file is used instead.

## cut (default `d`)

Save the paths of selected files to the clipboard as files to be moved.
If there are no selected files, the path of the current file is used instead.

## paste (default `p`)

Copy/Move files in the clipboard to the current working directory.
A custom `paste` command can be defined to override this default.

## clear (default `c`)

Clear file paths in the clipboard.

## sync

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 `<c-l>`)

Synchronize the terminal and redraw the screen.

## load

Load modified files and directories.
This command is automatically called when required.

## reload (default `<c-r>`)

Flush the cache and reload all files and directories.

## 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 built-in method.
A custom `rename` command can be defined to override this default.

## 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 at 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 filename 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 filename 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` 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` (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.

## echo

Print the given arguments to the message line at the bottom.

## echomsg

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.
If the argument is `-`, change to the previous directory stored in the special bookmark `'`.

## select

Change the current file selection to the given argument.

## source

Read the configuration file given in the argument.

## push

Simulate key pushes given in the argument.

## addcustominfo

Update the `custom` info and `.Stat.CustomInfo` field of the given file with the given string.
The info string may contain ANSI escape codes to further customize its appearance.
If no info is provided, clear the file's info instead.

## calcdirsize

Calculate the total size for each of the selected directories.
Option `info` should include `size` and option `dircounts` should be disabled to show this size.
If the total size of a directory is not calculated, it will be shown as `-`.

## clearmaps

Remove all keybindings associated with the `map`, `nmap` and `vmap` command.
This command can be used in the config file to remove the default keybindings.
For safety purposes, `:` is left mapped to the `read` command, and `cmap` keybindings are retained so that it is still possible to exit `lf` using `:quit`.

## tty-write

Write the given string to the tty.
This is useful for sending escape sequences to the terminal to control its behavior (e.g. OSC 0 to set the window title).
Using `tty-write` is preferred over directly writing to `/dev/tty` because the latter is not synchronized and can interfere with drawing the UI.

## visual (default `V`)

Switch to Visual mode.
If already in Visual mode, discard the visual selection and stay in Visual mode.

# VISUAL MODE COMMANDS

## visual-accept (default `V`)

Add the visual selection to the selection list, quit Visual mode and return to Normal mode.

## visual-unselect

Remove the visual selection from the selection list, quit Visual mode and return to Normal mode.

## visual-discard (default `<esc>`)

Discard the visual selection, quit Visual mode and return to Normal mode.

## visual-change (default `o`)

Go to the other end of the current Visual mode selection.

# COMMAND-LINE MODE COMMANDS

The prompt character specifies which of the several Command-line modes you are in.
For example, the `read` command takes you to the `:` mode.

When the cursor is at the first character in `:` mode, pressing one of the keys `!`, `$`, `%`, or `&` takes you to the corresponding mode.
You can go back with `cmd-delete-back` (`` by default).

The command line commands should be mostly compatible with readline keybindings.
A character refers to a Unicode code point, a word consists of letters and digits, and a Unix word consists of any non-blank characters.

## cmd-insert

Insert the character given in the argument.
This command is automatically called when required.

## cmd-escape (default `<esc>`)

Quit Command-line mode and return to Normal mode.

## cmd-complete (default `<tab>`)

Autocomplete the current word.

## cmd-menu-complete, cmd-menu-complete-back

Autocomplete the current word with the menu selection.
You need to assign keys to these commands (e.g. `cmap <tab> cmd-menu-complete; cmap  cmd-menu-complete-back`).
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-menu-discard

Discard the currently selected match in menu completion and close the menu.

## cmd-enter (default `<c-j>` and `<enter>`)

Execute the current line.

## cmd-interrupt (default `<c-c>`)

Interrupt the current shell-pipe command and return to the Normal mode.

## cmd-history-next (default `<c-n>` and `<down>`), cmd-history-prev (default `<c-p>` and ``)

Go to the next/previous entry in the command history.
If part of the command is already typed, then only matching entries will be considered, and consecutive duplicate entries are skipped.

## cmd-left (default `<c-b>` and `<left>`), cmd-right (default `<c-f>` and `<right>`)

Move the cursor to the left/right.

## cmd-home (default `<c-a>` and `<home>`), cmd-end (default `<c-e>` and `<end>`)

Move the cursor to the beginning/end of the line.

## cmd-delete (default `<c-d>` and `<delete>`)

Delete the next character.

## cmd-delete-back (default ``)

Delete the previous character.
When at the beginning of a prompt, returns either to Normal mode or to `:` mode.

## cmd-delete-home (default `<c-u>`), cmd-delete-end (default `<c-k>`)

Delete everything up to the beginning/end of the line.

## cmd-delete-unix-word (default `<c-w>`)

Delete the previous Unix word.

## cmd-yank (default `<c-y>`)

Paste the buffer content containing the last deleted item.

## cmd-transpose (default `<c-t>`)

Swap the characters before and after the cursor, then move the cursor forward.
If there is no character after the cursor, swap the previous two characters instead.

## cmd-transpose-word (default `<a-t>`)

Swap the words before and after the cursor, then move the cursor forward.
If there is no word after the cursor, swap the previous two words instead.

## cmd-word (default `<a-f>`), cmd-word-back (default `<a-b>`)

Move the cursor by one word in the forward/backward direction.

## cmd-delete-word (default `<a-d>`)

Delete the next word in the forward direction.

## cmd-delete-word-back (default `<a-backspace>`)

Delete the previous word in the backward direction.

## cmd-capitalize-word (default `<a-c>`), cmd-uppercase-word (default `<a-u>`), cmd-lowercase-word (default `<a-l>`)

Capitalize/uppercase/lowercase the current word and jump to the next word.

# SETTINGS

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, the find command starts matching patterns from the beginning of filenames, otherwise, it can match at an arbitrary position.

## autoquit (bool) (default true)

Automatically quit the server when there are no clients left connected.

## borderfmt (string) (default `\033[0m`)

Format string of border characters.

## borderstyle (string) (default `box`)

Border style used by `drawbox`.

The following styles are supported:

	box           outline around all panes and separators between them
	roundbox      like `box`, but with rounded outer corners
	outline       outline around all panes
	roundoutline  like `outline`, but with rounded outer corners
	separators    separators between panes

## 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 has its preview cache disabled.
The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next filename to be previewed respectively.
Preview cleaning is disabled when the value of this option is left empty.

## copyfmt (string) (default `\033[7;33m`)

Format string of the indicator for files to be copied.

## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt (string) (default `\033[7m`), cursorpreviewfmt (string) (default `\033[4m`)

Format strings for highlighting the cursor.
`cursoractivefmt` applies in the current directory pane,
`cursorparentfmt` applies in panes that show parents of the current directory,
and `cursorpreviewfmt` applies in panes that preview directories.

The default is to make the active cursor and the parent directory cursor inverted. The preview cursor is underlined.

Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, `\033[7;2m` for dimmed inverted text (visibility varies by terminal), `\033[7;90m` for inverted text with grey (aka "brightblack") background.

If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.

## cutfmt (string) (default `\033[7;31m`)

Format string of the indicator for files to be cut.

## dircounts (bool) (default false)

When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`.
This information needs to be calculated by reading the directory and counting the items inside.
Therefore, this option is disabled by default for performance reasons.
This option only has an effect when `info` has a `size` field and the pane is wide enough to show the information.
9999 items are counted per directory at most, and bigger directories are shown as `9999+`.

## dirfirst (bool) (default true)

Show directories first above regular files.
With `dircounts` enabled, sorting by `size` always separates directories and files, regardless of `dirfirst`.

## 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 borders around panes using box drawing characters.

## dupfilefmt (string) (default `%f.~%n~`)

Format string of filename 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 the base name (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates.

## errorfmt (string) (default `\033[7;31;47m`)

Format string of error messages shown in the bottom message line.

If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.

## filesep (string) (default `\n`)

File separator used in environment variables `fs`, `fv` and `fx`.

## filtermethod (string) (default `text`)

How filter command patterns are treated.
Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
See `SEARCHING FILES` for more details.

## 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.

## hidden (bool) (default false)

Show hidden files.
On Unix systems, hidden files are determined by the value of `hiddenfiles`.
On Windows, files with hidden attributes are also considered hidden files.

## hiddenfiles ([]string) (default `.*` for Unix and `` for Windows)

List of hidden file glob patterns.
Patterns can be given as relative or absolute paths.
Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges.
In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak`

## history (bool) (default true)

Save command history.

## icons (bool) (default false)

Show icons before each item in the list.

## ifs (string) (default ``)

Sets `IFS` variable in shell commands.
It works by adding the assignment to the beginning of the command string as `IFS=...; ...`.
The reason is that `IFS` variable is not inherited by the shell for security reasons.
This method assumes a POSIX shell syntax 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 search patterns. See also `sortignorecase`.

## ignoredia (bool) (default true)

Ignore diacritics in search patterns. See also `sortignoredia`.

## incfilter (bool) (default false)

Apply filter pattern after each keystroke during filtering.

## incsearch (bool) (default false)

Jump to the first match after each keystroke during searching.

## info ([]string)  (default ``)

A list of information that is shown for directory items at the right side of the pane.

The following information types are supported:

	perm      file permission
	user      user name
	group     group name
	size      file size
	time      time of last data modification
	atime     time of last access
	btime     time of file birth
	ctime     time of last status (inode) change
	custom    property defined via `addcustominfo` (empty by default)

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.

## menufmt (string) (default `\033[0m`)

Format string of the menu.

## menuheaderfmt (string) (default `\033[1m`)

Format string of the header row in the menu.

## menuselectfmt (string) (default `\033[7m`)

Format string of the currently selected item in the menu.

## mergeindicators (bool) (default false)

When `mergeindicators` is enabled, tag and selection indicators are drawn in a single column to reduce the gap before filenames.
If a file is both tagged and selected, the tag uses the selection format (e.g. `copyfmt`) instead of `tagfmt`.

## mouse (bool) (default false)

Send mouse events as input.

## number (bool) (default false)

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`), numbercursorfmt (string) (default ``)

Format strings for highlighting line numbers.
`numberfmt` applies to all lines.
`numbercursorfmt` applies to the cursor line and falls back to `numberfmt` when left empty.

## period (int) (default 0)

Set the interval in seconds for periodic checks of directory updates.
This works by periodically calling the `load` command.
Note that directories are already updated automatically in many cases.
This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf.
Periodic checks are disabled when the value of this option is set to zero.

## preload (bool) (default false)

Allow previews to be generated in advance using the `previewer` script as the user navigates through the filesystem.

## preserve ([]string) (default `mode`)

List of attributes that are preserved when copying files.
Currently supported attributes are `mode` (i.e. access mode) and `timestamps` (i.e. modification time and access time).
Note that preserving other attributes like ownership or change/birth timestamps is desirable, but not portably supported in Go.

## preview (bool) (default true)

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 are considered binary and displayed as `binary` if the read portion contains a control character other than bell, backspace, tab, newline, vertical tab, form feed, carriage return, escape or delete. 

## previewer (string) (default ``) (not filtered if empty)

Set the path of a previewer file to filter the content of regular files for previewing.
The file should be executable.
The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, (5) vertical position, and (6) mode ("preview" or "preload").
SIGPIPE signal is sent when enough lines are read.
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled.
This means that if the file is selected in the future, the previewer is called once again.
Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
If the `preload` option is enabled, then this will be called with `preload` as the mode when preloading file previews.
Refer to the [PREVIEWING FILES section](https://github.com/gokcehan/lf/blob/master/doc.md#previewing-files) for more information about how to configure custom previews.

## 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.

The following special expansions are supported:

	%f        file name
	%h        host name
	%u        user name
	%w        working directory
	%d        working directory (with trailing path separator)
	%F        current filter
	%S        spacer to right-align the following parts (can be used once)

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 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, the current line shows the absolute position, otherwise nothing is shown.

## reverse (bool) (default false)

Reverse the direction of sort.

## rulerfile (string) (default ``)

Set the path of the ruler file.
If not set, then a default template will be used for the ruler.
Refer to the [RULER section](https://github.com/gokcehan/lf/blob/master/doc.md#ruler) for more information about how the ruler file works.

## rulerfmt (string) (default ``)

Format string of the ruler shown in the bottom right corner.
When set, it will be used along with `statfmt` to draw the ruler, and `rulerfile` will be ignored.
However, using `rulerfile` is preferred and this option is provided for backwards compatibility.

The following special expansions are supported:

	%a        pressed keys
	%p        progress of file operations
	%m        number of files to be cut (moved)
	%c        number of files to be copied
	%s        number of selected files
	%v        number of visually selected files
	%t        number of shown files in the current directory
	%h        number of hidden files in the current directory
	%f        current filter
	%i        cursor position
	%P        scroll percentage
	%d        amount of free disk space

Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (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_<name>}` (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.

## scrolloff (int) (default 0)

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 half the 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.

## searchmethod (string) (default `text`)

How search command patterns are treated.
Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
See `SEARCHING FILES` for more details.

## selectfmt (string) (default `\033[7;35m`)

Format string of the indicator for files that are selected.

## selmode (string) (default `all`)

Selection mode for commands.
When set to `all` it will use the selected files from all directories.
When set to `dir` it will only use the selected files in the current directory.

## 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.

## showbinds (bool) (default true)

Show bindings associated with pressed keys.

## sizeunits (string) (default `binary`)

Determines whether file sizes are displayed using binary units (`1K` is 1024 bytes) or decimal units (`1K` is 1000 bytes).

## smartcase (bool) (default true)

Override `ignorecase` option for searching 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.

The following sort types are supported:

	natural   file name (track_2.flac comes before track_10.flac)
	name      file name (track_10.flac comes before track_2.flac)
	ext       file extension
	size      file size
	time      time of last data modification
	atime     time of last access
	btime     time of file birth
	ctime     time of last status (inode) change
	custom    property defined via `addcustominfo` (empty by default)

## sortignorecase (bool) (default true)

Ignore case when sorting. See also `ignorecase`.

## sortignoredia (bool) (default true)

Ignore diacritics when sorting. See also `ignoredia`.

## 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.
This option has no effect unless `rulerfmt` is also set.
Using `rulerfile` is preferred and this option is provided for backwards compatibility.

The following special expansions are supported:

	%p        file permission
	%c        link count
	%u        user name
	%g        group name
	%s        file size
	%S        file size (left-padded with spaces to a fixed width of 5 characters)
	%t        time of last data modification
	%l        link target
	%m        current mode
	%M        current mode (displaying `NORMAL` instead of a blank string in Normal mode)

The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.

## tabstop (int) (default 8)

Number of space characters to show for horizontal tabulation (U+0009) character.

## tagfmt (string) (default `\033[31m`)

Format string of the tags.

If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.

## tempmarks (string) (default ``)

Marks to be considered temporary (e.g. `abc` refers to marks `a`, `b`, and `c`).
These marks are not synced to other clients and they are not saved in the bookmarks file.
Note that the special bookmark `'` is always treated as temporary and it does not need to be specified.

## terminalcursor (string) (default `default`)

Set the appearance of the terminal cursor for prompts shown in the bottom line.
Currently supported values are `default`, `block`, `underline`, `bar`, `blinkblock`, `blinkunderline` and `blinkbar`.

## 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 `~`)

The truncate character that is shown at the end when the filename does not fit into the pane.

## truncatepct (int) (default 100)

When a filename is too long to be shown completely, the available space will be partitioned into two parts.
`truncatepct` is a percentage value between 0 and 100 that determines the size of the first part, which will be shown at the beginning of the filename.
The second part uses the rest of the available space, and will be shown at the end of the filename.
Both parts are separated by the truncation character (`truncatechar`).
Truncation is not applied to the file extension.

For example, with the filename `very_long_filename.txt`:

- `set truncatepct 100` -> `very_long_filena~.txt` (default)

- `set truncatepct 50`  -> `very_lon~filename.txt`

- `set truncatepct 0`   -> `~ry_long_filename.txt`

## visualfmt (string) (default `\033[7;36m`)

Format string of the indicator for files that are visually selected.

## waitmsg (string) (default `Press any key to continue`)

String shown after commands of shell-wait type.

## watch (bool) (default false)

Watch the filesystem for changes using `fsnotify` to automatically refresh file information.
FUSE is currently not supported due to limitations in `fsnotify`.

## wrapscan (bool) (default true)

Searching can wrap around the file list.

## wrapscroll (bool) (default false)

Scrolling can wrap around the file list.

## user_{option} (string) (default none)

Any option that is prefixed with `user_` is a user-defined option and can be set to any string.
Inside a user-defined command, the value will be provided in the `lf_user_{option}` environment variable.
These options are not used by lf and are not persisted.

# ENVIRONMENT VARIABLES

The following variables are exported for shell commands:
These are referred 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).

## fv

Visually selected file(s) separated with the value of `filesep` option as full path(s).

## fx

Selected file(s) (i.e. `fs`, never `fv`) if there are any selected files, otherwise current file selection (i.e. `f`).

## id

Id of the running client.

## PWD

Present working directory.

## OLDPWD

Initial working directory.

## LF_LEVEL

The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf.
You can add the value of this variable to your shell prompt to make it clear that your shell runs inside lf.
For example, with POSIX shells, you can use `[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) "` in your shell configuration file (e.g. `~/.bashrc`).

## OPENER

If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in macOS, `xdg-open` in others.

## EDITOR

If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to `vi` on Unix, `notepad` in Windows.

## PAGER

If this variable is set in the environment, use the same value. Otherwise, this is set to `less` on Unix, `more` in Windows.

## SHELL

If this variable is set in the environment, use the same value. Otherwise, this is set to `sh` on Unix, `cmd` in Windows.

## lf

Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string `lf`.

## lf_{option}

Value of the {option}.

## lf_user_{option}

Value of the user_{option}.

## lf_flag_{flag}

Value of the command line {flag}.

## lf_width, lf_height

Width/Height of the terminal.

## lf_count

Value of the count associated with the current command.

## lf_mode

Current mode that `lf` is operating in.
This is useful for customizing keybindings depending on what the current mode is.
Possible values are `compmenu`, `delete`, `rename`, `filter`, `find`, `mark`, `search`, `command`, `shell`, `pipe` (when running a shell-pipe command), `normal`, `visual` and `unknown`.

# 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-load

This shell command can be defined to be executed after loading a directory.
It provides the files inside the directory as arguments.

## on-focus-gained

This shell command can be defined to be executed when the terminal gains focus.

## on-focus-lost

This shell command can be defined to be executed when the terminal loses focus.

## on-init

This shell command can be defined to be executed after initializing and connecting to the server.

## 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 quitting.

# PREFIXES

The following command prefixes are used by lf:

	:  read (default)  built-in/custom command
	$  shell           shell command
	%  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 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.
Visual mode mappings are defined the same way Normal mode mappings are defined.

# SYNTAX

Characters from `#` to newline are comments and ignored:

	# comments start with `#`

The following commands (`set`, `setlocal`, `map`, `nmap`, `vmap`, `cmap`, and `cmd`) are used for configuration.

Command `set` is used to set an option which can be a boolean, integer, or string:

	set hidden         # boolean enable
	set hidden true    # boolean enable
	set nohidden       # boolean disable
	set hidden false   # boolean disable
	set hidden!        # boolean toggle
	set scrolloff 10   # integer value
	set sortby time    # string value without quotes
	set sortby 'time'  # string value with single quotes (whitespace)
	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 a boolean or string.
Currently supported local options are `dircounts`, `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, `sortby`, `sortignorecase` and `sortignoredia`.

	setlocal /foo/bar hidden         # boolean enable
	setlocal /foo/bar hidden true    # boolean enable
	setlocal /foo/bar nohidden       # boolean disable
	setlocal /foo/bar hidden false   # boolean disable
	setlocal /foo/bar hidden!        # boolean toggle
	setlocal /foo/bar sortby time    # string value without quotes
	setlocal /foo/bar sortby 'time'  # string value with single quotes (whitespace)
	setlocal /foo/bar sortby "time"  # string value with double quotes (backslash escapes)

Command `map` is used to bind a key in Normal and Visual mode to a command which can be a built-in command, custom command, or shell command:

	map gh cd ~        # built-in command
	map D trash        # custom command
	map i $less $f     # shell command
	map U !du -csh *   # waiting shell command

Command `nmap` does the same but for Normal mode only.

Command `vmap` does the same but for Visual mode only.

Overview of which map command works in which mode:

	map                Normal, Visual
	nmap               Normal
	vmap               Visual
	cmap               Command-line

Command `cmap` is used to bind a key on the command line to a command line command or any other command:

	cmap <c-g> cmd-escape
	cmap <a-i> set incsearch!

You can delete an existing binding by leaving the expression empty:

	map gh             # deletes 'gh' mapping in Normal and Visual mode
	nmap v             # deletes 'v' mapping in Normal mode
	vmap o             # deletes 'o' mapping in Visual mode
	cmap <c-g>         # deletes '<c-g>' mapping

Command `cmd` is used to define a custom command:

	cmd usage $du -h -d1 | less

You can delete an existing command by leaving the expression empty:

	cmd trash          # deletes 'trash' command

If there is no prefix then `:` is assumed:

	map zt set info time

An explicit `:` can be provided to group statements until a newline which is especially useful for `map` and `cmd` commands:

	map st :set sortby time; set info time

If you need multiline you can wrap statements in `{{` and `}}` after the proper prefix.

	map st :{{
	    set sortby time
	    set info time
	}}

# KEY MAPPINGS

Regular keys are assigned to a command with the usual syntax:

	map a down

Keys combined with the Shift key simply use the uppercase letter:

	map A down

Special keys are written in between `<` and `>` characters and always use lowercase letters:

	map <enter> down

Angle brackets can be assigned with their special names:

	map <lt> down
	map <gt> down

Function keys are prefixed with an `f` character:

	map <f-1> down

Keys combined with the Ctrl key are prefixed with a `c` character:

	map <c-a> down

Keys combined with the Alt key are assigned in two different ways depending on the behavior of your terminal.
Older terminals (e.g. xterm) may set the 8th bit of a character when the Alt key is pressed.
On these terminals, you can use the corresponding byte for the mapping:

	map á down

Newer terminals (e.g. gnome-terminal) may prefix the key with an escape character 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 an `a` character:

	map <a-a> down

It is possible to combine special keys with modifiers:

	map <a-enter> down

Combining multiple modifiers (e.g. `Ctrl+Shift+Space`) is not supported.

Note that lf's key mapping syntax is similar to Vim's, but not identical.
Some special keys and modifiers use different names and separators, and key names are matched literally (i.e. no case-folding, no aliases), so some familiar forms will not work:

	map <enter> down  # not <Enter>, <Return> or <CR>
	map <f-1> down    # not <F1>
	map <a-j> down    # not <A-j> or <M-j> (Meta)
	map <m-2> down    # not <RightMouse>
	map <m-up> down   # not <ScrollWheelUp>

WARNING: Some key combinations will likely be intercepted by your OS, window manager, or terminal.
Other key combinations may not be distinguishable by lf, depending on how the terminal reports them (e.g. `Ctrl+h` may be reported as `backspace` 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 an `m` character:

	map <m-1> down  # primary
	map <m-2> down  # secondary
	map <m-3> down  # middle
	map <m-4> down  # thumb next
	map <m-5> down  # thumb prev
	map <m-6> down
	map <m-7> down
	map <m-8> down

Mouse wheel events are also prefixed with an `m` character:

	map <m-up>    down
	map <m-down>  down
	map <m-left>  down
	map <m-right> 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 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.

This is mainly useful for two purposes.
First, it can be used to map a command with a command count:

	map <c-j> push 10j

Second, it can be used to avoid typing the name when a command takes arguments:

	map r push :rename<space>

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 the selected file(s) to trash.
A first attempt to write such a command may look like this:

	cmd trash ${{
	    mkdir -p ~/.trash
	    if [ -z "$fs" ]; then
	        mv "$f" ~/.trash
	    else
	        IFS="$(printf '\n\t')"; mv $fs ~/.trash
	    fi
	}}

We check `$fs` to see if there are any selected files.
Otherwise, we just delete the current file.
Since this is such a common pattern, a separate `$fx` variable is provided.
We can use this variable to get rid of the conditional:

	cmd trash ${{
	    mkdir -p ~/.trash
	    IFS="$(printf '\n\t')"; mv $fx ~/.trash
	}}

The trash directory is checked each time the command is executed.
We can move it outside of the command so it would only run once at startup:

	${{ mkdir -p ~/.trash }}

	cmd trash ${{ IFS="$(printf '\n\t')"; mv $fx ~/.trash }}

Since these are one-liners, we can drop `{{` and `}}`:

	$mkdir -p ~/.trash

	cmd trash $IFS="$(printf '\n\t')"; mv $fx ~/.trash

Finally, note that we set 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 cause flickering on the screen for short commands and similar distractions for longer commands.

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.

For example, the following rename command prompts for overwrite in the statline if there is an existing file with the given name:

	cmd rename %mv -i $f $1

You can also output error messages in the command and they will show up in the statline.
For example, an alternative rename command may look like this:

	cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1

Note that input is line buffered and output and error are byte buffered.

# WAITING SHELL COMMANDS

Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished.
These can be useful to see the output of a program before the UI is resumed.
Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline.

# ASYNCHRONOUS SHELL COMMANDS

Asynchronous shell commands are used to start a command in the background and then resume operation without waiting for the command to finish.
Stdin, stdout, and stderr of the command 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 internally to notify file selection changes to other clients.

To use this feature, you need to use a client which supports communicating with a Unix domain socket.
OpenBSD implementation of netcat (nc) is one such example.
You can use it to send a command to the socket file:

	echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp/lf-$(id -u)}/lf.sock

Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such.
When using lf, you do not need to specify the address of the socket file.
This is the recommended way of using remote commands since it is shorter and immune to socket file address changes:

	lf -remote 'send echo hello world'

In this command `send` is used to send the rest of the string as a command to all connected clients.
You can optionally give it an ID number to send a command to a single client:

	lf -remote 'send 1234 echo hello world'

All clients have a unique ID number but you may not be aware of the ID number when you are writing a command.
For this purpose, an `$id` variable is exported to the environment for shell commands.
The value of this variable is set to the process ID of the client.
You can use it to send a remote command from a client to the server which in return sends a command back to itself.
So now you can display a message in the current client by calling the following in a shell command:

	lf -remote "send $id echo hello world"

Since lf does not have control flow syntax, remote commands are used for such needs.
For example, you can configure the number of columns in the UI with respect to the terminal width as follows:

	cmd recol %{{
	    if [ $lf_width -le 80 ]; then
	        lf -remote "send $id set ratios 1:2"
	    elif [ $lf_width -le 160 ]; then
	        lf -remote "send $id set ratios 1:2:3"
	    else
	        lf -remote "send $id set ratios 1:2:3:5"
	    fi
	}}

In addition, the `query` command can be used to obtain information about a specific lf instance by providing its ID:

	lf -remote "query $id maps"

The following types of information are supported:

	maps     list of mappings created by the 'map', 'nmap' and 'vmap' command
	nmaps    list of mappings created by the 'nmap' and 'map' command
	vmaps    list of mappings created by the 'vmap' and 'map' command
	cmaps    list of mappings created by the 'cmap' command
	cmds     list of commands created by the 'cmd' command
	jumps    contents of the jump list, showing previously visited locations
	history  list of previously executed commands on the command line
	files    list of files in the currently open directory as displayed by lf, empty if dir is still loading

When listing mappings the characters in the first column are:

	n  Normal
	v  Visual
	c  Command-line

This is useful for scripting actions based on the internal state of lf.
For example, to select a previous command using fzf and execute it:

	map <a-h> ${{
	    clear
	    cmd=$(
	        lf -remote "query $id history" |
	        awk -F'\t' 'NR > 1 { print $NF}' |
	        sort -u |
	        fzf --reverse --prompt='Execute command: '
	    )
	    lf -remote "send $id $cmd"
	}}

The `list` command prints the IDs of all currently connected clients:

	lf -remote 'list'

There is also a `quit` command to quit the server when there are no connected clients left, and a `quit!` command to force quit the server by closing client connections first:

	lf -remote 'quit'
	lf -remote 'quit!'

Lastly, the commands `conn` and `drop` connect or disconnect ID to/from the server:

	lf -remote 'conn $id'
	lf -remote 'drop $id'

These are internal and generally not needed by users.

# FILE OPERATIONS

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 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, named pipes, and sockets are skipped and links are not followed.
Moving is performed using the rename operation of the underlying OS.
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
Operation errors are shown in the message line as well as the log file and they do not prematurely terminate the corresponding file operation.

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 built-in implementation.
You can use the following example as a starting point:

	cmd paste %{{
	    load=$(cat ~/.local/share/lf/files)
	    mode=$(echo "$load" | sed -n '1p')
	    list=$(echo "$load" | sed '1d')
	    if [ $mode = 'copy' ]; then
	        cp -R $list .
	    elif [ $mode = 'move' ]; then
	        mv $list .
	        rm ~/.local/share/lf/files
	        lf -remote 'send clear'
	    fi
	}}

Some useful things to be considered are to use the backup (`--backup`) and/or preserve attributes (`-a`) options with `cp` and `mv` commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use `rsync` command with progress bar option for copying and feed the progress to the client periodically with remote `echo` calls.

By default, lf does not assign `delete` command to a key to protect new users.
You can customize file deletion by defining a `delete` command.
You can also assign a key to this command if you like.
An example command to move selected files to a trash folder and remove files completely after a prompt 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.

The searching mechanism is implemented with commands `search` (default `/`), `search-back` (default `?`), `search-next` (default `n`), and `search-prev` (default `N`).
You can set `searchmethod` to `glob` to match using a glob pattern.
Globbing supports `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges.
You can set `searchmethod` to `regex` to match using a regex pattern.
For a full overview of Go's RE2 syntax, see https://pkg.go.dev/regexp/syntax.
You can enable `incsearch` option to jump to the current match at each keystroke while typing.
In this mode, you can either use `cmd-enter` to accept the search or use `cmd-escape` to cancel the search.
You can also map some other commands with `cmap` to accept the search and execute the command immediately afterwards.
For example, you can use the right arrow key to finish the search and open the selected file with the following mapping:

	cmap <right> :cmd-enter; open

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 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 affect both searching and finding.
You can disable `wrapscan` 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 uppercase 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 an `open` command (default `l` and `<right>`) to configure file opening.
This command is only called when the current file is not a directory, otherwise, the directory is entered instead.
You can define it just as you would define any other command:

	cmd open $vi $fx

It is possible to use different command types:

	cmd open &xdg-open $f

You may want to use either file extensions or MIME types from `file` command:

	cmd open ${{
	    case $(file --mime-type -Lb $f) in
	        text/*) vi $fx;;
	        *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
	    esac
	}}

You may want to use `setsid` before your opener command to have persistent processes that continue to run after lf quits.

Regular shell commands (i.e. `$`) drop to 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
	        text/*) lf -remote "send $id \$vi \$fx";;
	        *) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
	    esac
	}}

Note that asynchronous shell commands run in their own process group by default so they do not require the manual use of `setsid`.

The following command is provided by default:

	cmd open &$OPENER $f

You may also use any other existing file openers as you like.
Possible options are `libfile-mimeinfo-perl` (executable name is `mimeopen`), `rifle` (ranger's default file opener), or `mimeo` to name a few.

# PREVIEWING FILES

lf previews files on the preview pane by printing the file until the end or 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 code, list contents of archive files or view PDF or image files to name a few.
For coloring lf recognizes ANSI escape codes.

To use this feature, you need to set the value of `previewer` option to the path of an executable file.
The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, (5) vertical position, and (6) mode ("preview" or "preload").
The output of the execution is printed in the preview pane.

Different types of files can be handled by matching by extension (or MIME type from the `file` command):

	#!/bin/sh

	case "$1" in
	    *.tar*) tar tf "$1";;
	    *.zip) unzip -l "$1";;
	    *.rar) unrar l "$1";;
	    *.7z) 7z l "$1";;
	    *.pdf) pdftotext "$1" -;;
	    *) highlight -O ansi "$1";;
	esac

Because files can be large, lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
Note that some programs may not respond well to SIGPIPE and will exit with a non-zero return code, which avoids caching.
You may add a trailing `|| true` command to avoid such errors:

	highlight -O ansi "$1" || true

You may also want to use the same script in your pager mapping as well:

	set previewer ~/.config/lf/pv.sh
	map i $~/.config/lf/pv.sh $f | less -R

For `less` pager, you may instead utilize `LESSOPEN` mechanism so that useful information about the file such as the full path of the file can still be displayed in the statusline below:

	set previewer ~/.config/lf/pv.sh
	map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f

Since the preview script is called for each file selection change, it may not generate previews fast enough if the user scrolls through files quickly.
To deal with this, the `preload` option can be set to enable file previews to be preloaded in advance.
If enabled, the preview script will be run on files in advance as the user navigates through them.
In this case, if the exit code of the preview script is zero, then the output will be cached in memory and displayed by lf (useful for text or sixel previews).
Otherwise, it will fall back to calling the preview script again when the file is actually selected (useful for previews managed by an external program).

# CHANGING DIRECTORY

lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory.
After quitting, it returns to the original directory where it is first launched like all shell programs.
If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository at
https://github.com/gokcehan/lf/tree/master/etc

There is a special command `on-cd` that runs a shell command when it is defined and the directory is changed.
You can define it just as you would define any other command:

	cmd on-cd &{{
	    bash -c '
	    # display git repository status in your prompt
	    source /usr/share/git/completion/git-prompt.sh
	    GIT_PS1_SHOWDIRTYSTATE=auto
	    GIT_PS1_SHOWSTASHSTATE=auto
	    GIT_PS1_SHOWUNTRACKEDFILES=auto
	    GIT_PS1_SHOWUPSTREAM=auto
	    git=$(__git_ps1 " (%s)")
	    fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f$git\033[0m"
	    lf -remote "send $id set promptfmt \"$fmt\""
	    '
	}}

If you want to send escape sequences to the terminal, you can use the `tty-write` command to do so.
The following xterm-specific escape sequence sets the terminal title to the working directory:

	cmd on-cd &{{
	    lf -remote "send $id tty-write \"\033]0;$PWD\007\""
	}}

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

Note that all shell command types can be used, but `%` and `&` are usually more appropriate, as `$` and `!` cause flickering and pauses respectively.

There is also a `pre-cd` command, that works like `on-cd`, but is run before the directory is actually changed.
Another related command is `on-load` which gets executed when loading a directory.

# LOADING DIRECTORY

Similar to `on-cd` there also is `on-load` that when defined runs a shell command after loading a directory.
It works well when combined with `addcustominfo`.

The following example can be used to display git indicators in the info column:

	cmd on-load &{{
	    cd "$(dirname "$1")" || exit 1
	    [ "$(git rev-parse --is-inside-git-dir 2>/dev/null)" = false ] || exit 0

	    cmds=""

	    for file in "$@"; do
	        case "$file" in
	            */.git|*/.git/*) continue;;
	        esac

	        status=$(git status --porcelain --ignored -- "$file" | cut -c1-2 | head -n1)

	        if [ -n "$status" ]; then
	            cmds="${cmds}addcustominfo \"${file}\" \"$status\"; "
	        else
	            cmds="${cmds}addcustominfo \"${file}\" ''; "
	        fi
	    done

	    if [ -n "$cmds" ]; then
	        lf -remote "send $id :$cmds"
	    fi
	}}

Another use case could be showing the dimensions of images and videos:

	cmd on-load &{{
	    cmds=""

	    for file in "$@"; do
	        mime=$(file --mime-type -Lb -- "$file")
	        case "$mime" in
	            # vector images cause problems
	            image/svg+xml)
	                ;;
	            image/*|video/*)
	                dimensions=$(exiftool -s3 -imagesize -- "$file")
	                cmds="${cmds}addcustominfo \"${file}\" \"$dimensions\"; "
	                ;;
	        esac
	    done

	    if [ -n "$cmds" ]; then
	        lf -remote "send $id :$cmds"
	    fi
	}}

# COLORS

lf tries to automatically adapt its colors to the environment.
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:

 1. default
 2. LSCOLORS (macOS/BSD ls)
 3. LS_COLORS (GNU ls)
 4. LF_COLORS (lf specific)
 5. colors file (lf specific)

Please refer to the corresponding man pages for more information about `LSCOLORS` and `LS_COLORS`.
`LF_COLORS` is provided with the same syntax as `LS_COLORS` in case you want to configure colors only for lf but not ls.
This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases.
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 `#` 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 those colors automatically.
Depending on your terminal, you should be able to select your colors from a 24-bit palette.
This is the recommended approach as colors used by other programs will also match each other.

Second, you can set the values of environment variables or colors file mentioned above for fine-grained customization.
Note that `LS_COLORS/LF_COLORS` are more powerful than `LSCOLORS` and they can be used even when GNU programs are not installed on the system.
You can combine this second method with the first method for 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 about how to color this line.

It is worth noting that lf uses as many colors as advertised by your terminal's entry in terminfo or infocmp databases on your system.
If an entry is not present, it falls back to an internal database.
If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the `$COLORTERM` variable to `truecolor` or ensuring `$TERM` is set to a value that ends with `-truecolor`.

Default lf colors are mostly taken from GNU dircolors defaults.
These defaults use 8 basic colors and bold attribute.
Default dircolors entries with background colors are simplified to avoid confusion with current file selection in lf.
Similarly, there are only file type matchings and extension matchings are left out for simplicity.
Default values are as follows given with their matching order in lf:

	ln  01;36
	or  31;01
	tw  01;34
	ow  01;34
	st  01;34
	di  01;34
	pi  33
	so  01;35
	bd  33;01
	cd  33;01
	su  01;32
	sg  01;32
	ex  01;32
	fi  00

Note that lf first tries matching file names and then falls back to file types.
The full order of matchings from most specific to least are as follows:

 1. Full Path (e.g. `~/.config/lf/lfrc`)
 2. Dir Name  (e.g. `.git/`) (only matches dirs with a trailing slash at the end)
 3. File Type (e.g. `ln`) (except `fi`)
 4. File Name (e.g. `README*`)
 5. File Name (e.g. `*README`)
 6. Base Name (e.g. `README.*`)
 7. Extension (e.g. `*.txt`)
 8. Default   (i.e. `fi`)

For example, given a regular text file `/path/to/README.txt`, the following entries are checked in the configuration and the first one to match is used:

 1. `/path/to/README.txt`
 2. (skipped since the file is not a directory)
 3. (skipped since the file is of type `fi`)
 4. `README.txt*`
 5. `*README.txt`
 6. `README.*`
 7. `*.txt`
 8. `fi`

Given a regular directory `/path/to/example.d`, the following entries are checked in the configuration and the first one to match is used:

 1. `/path/to/example.d`
 2. `example.d/`
 3. `di`
 4. `example.d*`
 5. `*example.d`
 6. `example.*`
 7. `*.d`
 8. `fi`

Note that glob-like patterns do not 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 into multiple lines in between double quotes by escaping newlines with backslashes as follows:

	export LF_COLORS="\
	~/Documents=01;31:\
	~/Downloads=01;31:\
	~/.local/share=01;31:\
	~/.config/lf/lfrc=31:\
	.git/=01;32:\
	.git*=32:\
	*.gitignore=32:\
	*Makefile=32:\
	README.*=33:\
	*.txt=34:\
	*.md=34:\
	ln=01;36:\
	di=01;34:\
	ex=01;32:\
	"

The `ln` entry supports the special value `target`, which will use the link target to select a style. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
Having such a long variable definition in a shell configuration file might be undesirable.
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
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 (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
The variable uses the same syntax as `LS_COLORS/LF_COLORS`.
Instead of colors, you should use single characters or symbols as values.
The `ln` entry supports the special value `target`, which will use the link target to select an icon. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated arrays with a `#` character to start comments until the end of the line.
Each line should contain 1-3 columns: a file type or file name pattern, the icon, and an optional icon color. Using only one column disables all rules for that type or name.
Do not forget to add `set icons true` to your `lfrc` to see the icons.
Default values are listed below in the order lf matches them:

	ln  l
	or  l
	tw  t
	ow  d
	st  t
	di  d
	pi  p
	so  s
	bd  b
	cd  c
	su  u
	sg  g
	ex  x
	fi  -

A sample icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons.example

A sample colored icons file can be found at
https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example

# RULER

The ruler can be configured using the `rulerfile` option (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
The contents of the ruler file should be a Go template which is then rendered to create the actual output (refer to https://pkg.go.dev/text/template for more details on the syntax).

The following data fields are exported:

	.Message          string              Includes internal messages, errors, and messages generated by the `echo`/`echomsg`/`echoerr` commands
	.Keys             string              Keys pressed by the user
	.Progress         []string            Progress indicators for copied, moved and deleted files
	.Copy             []string            List of files in the clipboard to be copied
	.Cut              []string            List of files in the clipboard to be moved
	.Select           []string            Selection list
	.Visual           []string            Visual selection
	.Index            int                 Index of the cursor
	.Total            int                 Number of visible files in the current working directory
	.Hidden           int                 Number of hidden files in the current working directory
	.All              int                 Number of all files in the current working directory
	.LinePercentage   string              Line percentage (analogous to `%p` for the `statusline` option in Vim)
	.ScrollPercentage string              Scroll percentage (analogous to `%P` for the `statusline` option in Vim)
	.Filter           []string            Filter currently being applied
	.Mode             string              Current mode ("NORMAL" for Normal mode, and "VISUAL" for Visual mode)
	.Options          map[string]string   The value of options (e.g. `{{.Options.hidden}}`)
	.UserOptions      map[string]string   The value of user-defined options (e.g. `{{.UserOptions.foo}}`)
	.Stat.Path        string              Path of the current file
	.Stat.Name        string              Name of the current file
	.Stat.Extension   string              Extension of the current file
	.Stat.Size        int64               Size of the current file
	.Stat.DirSize     int64               Total size of the current directory if calculated via `calcdirsize` (`-1` if not calculated)
	.Stat.DirCount    int                 Number of items in the current directory if the `dircounts` option is enabled (`-1` if the directory cannot be read)
	.Stat.Permissions string              Permissions of the current file
	.Stat.ModTime     string              Last modified time of the current file (formatted based on the `timefmt` option)
	.Stat.AccessTime  string              Last access time of the current file (formatted based on the `timefmt` option)
	.Stat.BirthTime   string              Birth time of the current file (formatted based on the `timefmt` option)
	.Stat.ChangeTime  string              Last status (inode) change time of the current file (formatted based on the `timefmt` option)
	.Stat.LinkCount   string              Number of hard links for the current file
	.Stat.User        string              User of the current file
	.Stat.Group       string              Group of the current file
	.Stat.Target      string              Target if the current file is a symbolic link, otherwise a blank string
	.Stat.CustomInfo  string              Custom property if defined via `addcustominfo`, otherwise a blank string

The following functions are exported:

	df       func() string                   Get an indicator representing the amount of free disk space available
	env      func(string) string             Get the value of an environment variable
	humanize func(int64) string              Express a file size in a human-readable format
	join     func([]string, string) string   Join a string array by a separator
	lower    func(string) string             Convert a string to lowercase
	substr   func(string, int, int) string   Get a substring based on starting index and length
	upper    func(string) string             Convert a string to uppercase

The special identifier `{{.SPACER}}` can be used to divide the ruler into sections that are spaced evenly from each other.

The default ruler file can be found at
https://github.com/gokcehan/lf/blob/master/etc/ruler.default

--- METRICS ---
- Files Extracted: 4
- Estimated Token Budget: ~40822 tokens
- Recency Window: Active (< 180 days)
- Canonical Reference: https://codewiki.google/github.com/gokcehan/lf
