I wrote on vxlabs about my macos/linux-focused setup for the minimal but fantastic console-based lf file manager.

Recently I had to work on some Windows desktops (I love all of the operating systems btw), and so I made a slightly more minimal lf setup there as well, which is documented in this note with step-by-step instructions.

As you can see in the screenshot, it looks almost like the stock setup, but it does have some useful additional features that I use often.

  • lfcd to stay in the directory you navigated to when exiting lf.
  • bat for the syntax highlighted preview of many types of text files.
  • Press :zi inside lf to use zoxide and fzf to jump to your most recent and ferquently used directories.
  • Press V to preview any other PDF, image file, many other types using QuickLook for Windows.

Install everything

winget install gokcehan.lf sharkdp.bat zoxide fzf vim.vim
# If you want to use the GUI quicklook tool to preview images / docs with `V`:
winget install QL-Win.QuickLook

Setup lfcd.ps1

By default when you exit from lf you are back in the directory you started from.

To make it so that it leaves you in the directory you navigated to, you have to install the lfcd.ps script.

First we edit the powershell profile to add the profile directory to the path:

notepad $profile.CurrentUserAllHosts

Add the following lines, save and restart powershell:

# add path containing this script to the path so that we can install scripts like lfcd.ps1 here
# https://stackoverflow.com/a/1018433/532513  
$ProfileRoot = (Split-Path $script:MyInvocation.MyCommand.Path)  
$env:path += ";$ProfileRoot"

Finally download the script from the lf github:

cd (Split-Path -Parent $profile.CurrentUserAllHosts)
curl -O https://raw.githubusercontent.com/gokcehan/lf/refs/heads/master/etc/lfcd.ps1

You can now invoke lfcd instead of lf to get the directory changing behaviour.

Setup lf configuration file

Ensure that your $env:USERPROFILE\AppData\Local\lf\lfrc file (create if required) looks like the following:

# this goes in $env:USERPROFILE\AppData\Local\lf\lfrc
# personally, I symlink it from my synced config files like this:
# cmd /c mklink lfrc $env:OneDriveConsumer\configs\dot-config-lf\lfrc.windows
 
# winget install gokcehan.lf sharkdp.bat zoxide fzf vim.vim
# If you want to use the GUI quicklook tool to preview images / docs with `V`:
# winget install QL-Win.QuickLook
 
# interpreter for shell commands
set shell powershell
 
# change the default open command to work in powerShell
cmd open &start $Env:f
# edit with vim
map e $vim $Env:f
# page through any file with bat
# paging=always so that shorter files don't immediately exit back to lf
map i $bat --paging=always $Env:f
# use "bat -p" (plain pager) also for viewing lf docs
cmd doc $lf -doc | bat -p
 
# on my powershell 7.4.6 this breaks, commenting out
#set shellflag "-cwa"
 
# refine selected file as I type
set incsearch true
 
# default, but with some separation before final %f, and after cwd
# otherwise I kept on interpreting cwd+file as cwd
# 💾 📁
set promptfmt "\033[32;1m%u@%h\033[0m:\033[34;1m%d 📁 \033[0m\033[1m%f\033[0m"
 
# https://github.com/gokcehan/lf/wiki/Integrations#quicklook
# winget install QL-Win.QuickLook
map V $C:\Users\cpbot\AppData\Local\Programs\QuickLook\QuickLook.exe $env:f
 
# install zoxide and fzf for the following commands to work
cmd z ${{
    [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("UTF-8")
    $result = ((zoxide query --exclude $PWD $args[0]) -replace "/", "//")
    lf -remote "send $env:id cd '$result'"
}}
 
cmd zi ${{
    [Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("UTF-8")
    $result=((zoxide query -i) -replace "/", "//")
    lf -remote "send $id cd '$result'"
}}
 
cmd on-cd &{{
    zoxide add "$PWD"
}}