Sign inDemoInstall

Package Overview
File Explorer

Install Socket

Protect your apps from supply chain attacks


lf is a terminal file manager. Source code can be found in the repository at This documentation can either be read from terminal using "lf -doc" or online at The following commands are provided by lf with default keybindings. The following commands are provided by lf without default keybindings. The following options can be used to customize the behavior of lf. The following variables are exported for shell commands. The configuration file should either be located in "$XDG_CONFIG_HOME/lf/lfrc" or "~/.config/lf/lfrc". A sample configuration file can be found at The following command prefixes are used by lf: The same evaluator is used for the command line and the configuration file. The difference is that prefixes are not necessary in the command line. Instead different modes are provided to read corresponding commands. Note that by default these modes are mapped to the prefix keys above. Characters from "#" to "\n" are comments and ignored. There are three special commands for configuration. "set" is used to set an option which could be bool (e.g. "set hidden", "set nohidden", "set hidden!"), int (e.g. "set scrolloff 10"), or string (e.g. "set sortby time"). "map" is used to bind a key to a command which could be built-in command (e.g. "map gh cd ~"), custom command (e.g. "map D trash"), or shell command (e.g. "map i $less "$f"", "map u !du -h . | less"). You can delete an existing binding by leaving the expression empty (e.g. "map gh"). "cmd" is used to define a custom command or delete an existing command by leaving the expression empty (e.g. "cmd trash"). If there is no prefix then ":" is assumed. An explicit ":" could be provided to group statements until a "\n" occurs. This is especially useful for "map" and "cmd" commands. If you need multiline you can wrap statements in "{{" and "}}" after the proper prefix. The usual way to map a key sequence is to assign it to a named or unnamed command. While this provides a clean way to remap builtin keys as well as other commands, it can be limiting at times. For this reason "push" command is provided by lf. This command is used to simulate key pushes given as its arguments. You can "map" a key to a "push" command with an argument to create various keybindings. This is mainly useful for two purposes. First, it can be used to map a command with a command count. Second, it can be used to avoid typing the name when a command takes arguments. One thing to be careful is that since "push" command works with keys instead of commands it is possible to accidentally create recursive bindings. These types of bindings create a deadlock when executed. For demonstration let us write a shell command to move selected file(s) to trash. A first attempt to write such a command may look like this: We check "$fs" to see if there are any marked 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. The trash directory is checked each time the command is executed. We can move it outside of the command so it would only run once at startup. Since these are one liners, we can drop "{{" and "}}". Finally note that we set "IFS" variable accordingly in the command. Instead we could use the "ifs" option to set it for all commands (e.g. "set ifs ':'"). This could be especially useful for interactive use (e.g. "rm $fs" would simply work). This option is not set by default as things may behave unexpectedly at other places. lf uses the underlying "cp" and "mv" shell commands for file operations. For this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy the file on the disk, but only records its name to memory. The actual file operation takes place when you do the "put" in which case the "cp" command is used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) followed by "put". These traditional names (e.g. "yank", "delete", and "put") are picked instead of the other common convention (e.g. copy and cut) to resemble the default keybinds for these operations. You can use "open-file" command to open a file. This is a special command called by "open" when the current file is not a directory. Normally a user maps the "open" command to a key (default "l") and customize "open-file" command as desired. You can define it just as you would define any other command. It is possible to use different command types. You may want to use either file extensions or mime types from "file" command. lf does not come bundled with a file opener. You can use any of the existing file openers as you like. Possible options are "open" (for Mac OS X only), "xdg-utils" (executable name is "xdg-open"), "libfile-mimeinfo-perl" (executable name is "mimeopen"), "rifle" (ranger's default file opener), or "mimeo" to name a few. lf previews files on the preview pane by printing the file until the end or the preview pane is filled. This output can be enhanced by providing a custom preview script for filtering. This can be used to highlight source codes, list contents of archive files or view pdf or image files as text to name few. For coloring lf recognizes ansi escape codes. In order to use this feature you need to set the value of "previewer" option to the path of an executable file. lf passes the current file name as the first argument and the height of the preview pane as the second argument when running this file. Output of the execution is printed in the preview pane. You may want to use the same script in your pager mapping as well if any. Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user. You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from "file" command. Extensions can then be used to match cleanly within a conditional. Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, "highlight" is recommended over "pygmentize" for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.


Version published


# LF

[Google Groups](!forum/lf-fm) | [Wiki](

[![Build Status](](
[![Join the chat at](](

> This is a work in progress. Use at your own risk.

`lf` (as in "list files") is a terminal file manager written in Go.
It is heavily inspired by ranger with some missing and extra features.
Some of the missing features are deliberately omitted
since it is better if they are handled by external tools.


## Features

- Cross-platform (Linux, OSX, BSDs, Windows (partial))
- Single binary without any runtime dependencies (except for terminfo database)
- Fast startup and low memory footprint (due to native code and static binaries)
- Server/client architecture to share file selection between multiple instances
- Custom commands as shell commands
- Sync (waiting and non-waiting) and async commands
- Fully customizable keybindings
- Preview filtering (for source highlight, archives, pdfs/images as text etc.)

## Non-Features

- Tabs or windows (handled by the window manager or the terminal multiplexer)
- Built-in pager (handled by your pager of choice)
- Image previews (cool but no standard available)

## May-Futures

- Bookmarks
- Colorschemes

## Installation

See [releases]( for pre-built binaries.

If you like to build from the source:

    go get -u

See [packages]( for community maintained packages.

## Usage

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

Run `lf -help` to see command line options.

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

See [etc](etc) directory to integrate `lf` to your shell or editor.
An example configuration file can also be found in this directory.


Last updated on 07 Nov 2016

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc