Manage Files with lf hero

Manage Files with lf

lf is a terminal file manager. Having to constantly change directories with the cd command and preview files with cat can be slow and repetitive. lf allows you to quickly navigate your filesystem and preview files with a single vim-like commands.

Install

Install it homebrew with the following command.

Terminal window
brew install lf

Using

Using lf is as simple as running the lf command which will pull up the file manager. You can use hjkl as arrow keys to navigate the files. You can also press o to open up a file in your editor.

Configuration

lf is configured with a file located at ~/.config/lf. Here are some simple default options that I like to set.

~/.config/lf/lfrc
set hidden
set icons
set number
set relativenumber
set shell fish
set promptfmt "\033[34;1m%d\033[0m\033[1m%f\033[0m"

You can add icon support by install my fish plugin:

Terminal window
fisher install joshmedeski/fish-lf-icons

Here’s a preview of what it looks like:

lf preview

I also like to have access to lf while inside neovim, so you can add the following plugin to your LazyVim setup.

return {
"lmburns/lf.nvim",
cmd = "Lf",
dependencies = { "nvim-lua/plenary.nvim", "akinsho/toggleterm.nvim" },
opts = {
winblend = 0,
highlights = { NormalFloat = { guibg = "NONE" } },
border = "single",
escape_quit = true,
},
keys = {
{ "<leader>ff", "<cmd>Lf<cr>", desc = "NeoTree" },
},
}

You’ll have to restart LazyVim, but after that you can press <space>+f+f to open lf as a floating window in the directory of the file you have open.

lf preview

Conclusion

I prefer lf over sidebar style file mangers and it is infinitely customizable for your needs. We discussed install it with homebrew, configuring it to show icons, and how to use it in Neovim. Check out the lf wiki to learn how to customize it more.

Sign-Up for New Posts

Stay in the loop and get the latest blog posts about dotfiles sent to your inbox.

man sitting at desk in front of a landscape of rivers leading to a mountain range

Dev Workflow Intro

Your guide to creating a powerful and intuitive development workflow in the terminal.

The terminal is a powerful tool for developers, but it can be overwhelming to know where to start. This guide will help you create a powerful development environment in the terminal. Here are some of the things you'll learn.

  • Install packages and keep them up-to-date
  • Design a minimalist, distraction-free, user-interface
  • Use familiar keyboard shortcuts
  • Manage multiple projects with ease
  • Integrate with Git and GitHub
Get Started