Skip to content
Joe Lim edited this page Jun 9, 2024 · 10 revisions

Useful tips

Enabling logging

Logging can be enabled for both the lf client and server using the -log option, which can be used to help troubleshoot errors.

lf client:

lf -log /path/to/lf.log

lf server:

lf -server -log /path/to/lf_server.log

Investigating crashes

If lf crashes, it will not restore the terminal settings, resulting in the printed stack trace being difficult to read. Since the stack trace is printed to stderr, it can be useful to redirect this to a file first:

lf 2> /path/to/lf.err

Known issues

There is CJK text residue on Windows

You may enable legacy console in command prompt options.

See https://github.com/gokcehan/lf/issues/644

Pressing l opens firefox instead of default text editor

Change open command to

cmd open &{{
	mimetype=$(file --brief --dereference --mime-type $f)
	defapp=$(xdg-mime query default $mimetype)
	case "$defapp" in 
	nvim.desktop)
        lf -remote "send $id \$nvim $f"
		;;
	vim.desktop)
        lf -remote "send $id \$vim $f"
		;;
	*)
		xdg-open $f
	esac
}}

Running shell command results in non-zero exit status

The error message running shell: exit status ... means you ran a shell command (e.g. $false) but it returned something other than 0 and hence did not run successfully. This should be resolved by fixing the issue with the command itself to ensure that it runs successfully.

However this is not always possible, and as an alternative you can suppress the failure so that lf doesn't report it. For example, to ignore errors when opening files using nvim:

cmd open $nvim "$f" || true

Mapping ctrl+i results in mapping tab

Many terminal emulators send the same terminal sequence when pressing ctrl+i or tab, which means programs like lf cannot distinguish between the two inputs. There are various other key combinations that cannot be distinguished, ctrl+i/tab is just one such example.

It is possible to check what key event is received by just pressing a key combination - if it is not bound to an action then an error message saying unknown mapping ... will show up.

Multiline shell commands don't work on Windows

On Windows, the default interpreter for shell commands is Windows CMD, which doesn't support multiline commands. So the following definition won't work:

cmd foobar !{{
    echo foo
    echo bar
}}

One workaround is to save the commands into a batch script, and then invoke it from lf:

foobar.bat:

@echo off

echo foo
echo bar

lfrc:

cmd foobar !foobar.bat

An alternative solution is to use a more modern shell like PowerShell instead of Windows:

set shell pwsh

cmd foobar !{{
    echo foo
    echo bar
}}