-
Notifications
You must be signed in to change notification settings - Fork 331
Tutorial
If you have go installed on your machine and want to build lf
yourself from the source, you can use the following command:
env CGO_ENABLED=0 go install -ldflags="-s -w" github.com/gokcehan/lf
Make sure you are not inside a directory with a Go module when you run this command and also $GOPATH/bin
is in your $PATH
variable.
On Windows, you need to modify this command to set environment variables properly depending on your shell.
On cmd
, you can use:
set CGO_ENABLED=0
go install -ldflags="-s -w" github.com/gokcehan/lf
On powershell
, you can use:
$env:CGO_ENABLED = '0'
go install -ldflags="-s -w" github.com/gokcehan/lf
Master branch is rarely broken so building from source should often be safe though new features may not always work as expected.
If you do not have go installed on your machine, you can grab one of the pre-built binaries from releases section. These are built regularly every couple of months once there are some interesting new features and/or important bug fixes. You can use a command similar to the following to install or update a binary from the command line:
curl -L https://github.com/gokcehan/lf/releases/latest/download/lf-linux-amd64.tar.gz | tar xzC ~/.local/bin
Do not forget to change os (i.e. linux
) and arch (i.e. amd64
) values to the appropriate values for your system.
Also make sure that the extracted directory (i.e. ~/.local/bin
) exists and it is in your $PATH
variable.
Lastly, you can see packages wiki to see if there is a package available for your system. Packages can be preferred since they may be easier to install and new versions are installed when you update your system. Also some of the instructions given below may already be available with a package.
Once installed, running lf
from shell should start lf
in the current directory until a quit
(default q
) command is received:
up
(default k
and <up>
) and down
(default j
and <down>
) commands move up and down in the list:
half-up
(default <c-u>
) and half-down
(default <c-d>
) commands move half a page at a time:
page-up
(default <c-b>
and <pgup>
) and page-down
(default <c-f>
and <pgdn>
) commands move a full page at a time:
updir
(default h
and <left>
) command moves to parent directory and open
(default l
and <right>
) command opens the current directory or runs the default file opener on your system:
top
(default gg
and <home>
) and bottom
(default G
and <end>
) commands move to the beginning and end of the list:
toggle
(default <space>
) command toggles selection in the current file, invert
(default v
) command inverts selections in the current directory, and unmark
(default u
) command unmarks all selections:
copy
(default y
) command copies the current file or selections, cut
(default d
) command cuts the current file or selections, paste
(default p
) command pastes the copied or cut files to the current directory, and clear
(default c
) command clears copied or cut files:
read
(default :
) command reads a builtin or custom command:
shell
(default $
) command runs a command in the shell:
shell-pipe
(default %
) command runs a command in the shell while piping the input from the ui and output to the ui:
shell-wait
(default !
) command runs a command in the shell waits for a key press afterwards:
shell-async
(default &
) command runs a command in the background:
search
(default /
) command reads a pattern to search, search-back
(default ?
) command searches in the opposite direction, search-next
(default n
) and search-prev
(default N
) find the next and previous file matching the pattern:
Some default keybindings are provided (prefixed with z
) to toggle options or change their values:
Some default keybindings are provided (prefixed with s
) to change the values of sortby
and info
options:
Keybindings are provided to launch an editor (default e
), a pager (default i
), and a shell (default w
):
You can download the example configuration file and customize according to your needs. If you built from source you can simply copy this file from the repository:
mkdir -p ~/.config/lf
cp $GOPATH/src/github.com/gokcehan/lf/etc/lfrc.example ~/.config/lf/lfrc
Or if you installed a pre-built binary you can download this file from the repository:
mkdir -p ~/.config/lf
curl https://raw.githubusercontent.com/gokcehan/lf/master/etc/lfrc.example -o ~/.config/lf/lfrc
lf
starts in the current directory and changes the working directory accordingly when you move around.
On the other hand, when you quit lf
, the launching shell remains in the starting directory.
This is a limitation of shells since it is not possible for a program to change the working directory of the parent process.
However, you can define a shell function for this purpose as a workaround if you want to stay on the last visited directory when you quit:
Example scripts are provided in the repository for common shells. If you installed a pre-built binary you can download these example scripts from the repository:
mkdir -p ~/.config/lf
curl https://raw.githubusercontent.com/gokcehan/lf/master/etc/lfcd.sh -o ~/.config/lf/lfcd.sh
Then you need to source this file in your shell configuration file (e.g. ~/.bashrc
):
LFCD="$GOPATH/src/github.com/gokcehan/lf/etc/lfcd.sh" # source
LFCD="/path/to/lfcd.sh" # pre-built binary, make sure to use absolute path
if [ -f "$LFCD" ]; then
source "$LFCD"
fi
You can also bind a key for this command if you like:
bind '"\C-o":"lfcd\C-m"'
For other shells, see the comments in corresponding files for instructions.
It is often useful to open a file manager in multiple paths at the same time to copy files between directories.
Instead of implementing tabs or panes, lf
uses a server/client architecture for this purpose to fit your existing workflow.
A server process is automatically launched in the background when you run lf
command for the first time.
This process saves the names of files to be copied or moved so that you can copy files in one client and paste them in another.
This feature requires no configuration and it can be used with either multiple terminals or a multiplexer such as screen
or tmux
:
You can read the documentation for more in-depth information and the rest of the wiki for extras.