lf - The Light File Manager

lf

Config File

If you don't have a ~/.config/lf/lfrc file, you can probably find an example in /usr/share/examples/lf.

1cp -r /usr/share/examples/lf ~/.config/

Go straight to root with two keys.

1map g/ cd /

Have lf open a file with the default program when you press 'o', using the program mimeo.

1map o &mimeo $f

Change that default text editor to look at the extension first.

1cmd open ${{
2    case $(file --mime-type $f -b) in
3        application/x-sc) sc-im $fx;;
4        text/html) w3m $fx;;
5        text/*) $EDITOR $fx;;
6        video/*) nohup mpv $fx --really-quiet >/dev/null &;;
7        *) nohup $OPENER $fx >/dev/null &;;
8    esac
9}}

The idea here is to use the default $OPENER for lf, but first check extensions. Note the extra mpv commands to leave the video to play, without blocking the terminal.

Interesting Options

You can set the screen ratio with set ratios 1:2:3

That leaves it as a small initial pane, a medium pane, and a large pane for file previews.

Rename

The standard renaming is bad, because you have to re-type the file extension. Use this instead:

1# rename current file without overwrite
2cmd rename %echo 'name: ' ; read name ; extension="${f##*.}" && newname="$name.$extension"; [ "$f" = "$extension" ] && newname="$name"; [ ! -e "$newname" ] && mv "$f" "$newname" || echo file exists
3map r push :rename<enter>

If you try to rename image_1.png with this command, you can type in cats, and the result will be cats.png.

Image Previews

First, install ueberzug (to show images). Then clone the lfrun repo.

1git clone https://github.com/cirala/lfimg.git
2
3cd lfimg
4
5sudo make install