Skip to content
CatsDeservePets edited this page Feb 11, 2026 · 3 revisions

How do -print-selection/-selection-path work?

Both flags turn lf into a file picker:

  1. Select the files you want.
  2. Confirm the selection by opening any file.

lf then exits and returns the selected paths:

  • -print-selection prints them to stdout
  • -selection-path <path> writes them to the given file

If you quit lf without confirming, the selection is discarded.

How to change your shells directory using lf?

For security reasons, regular programs like lf can't change your shell's working directory.

A common workaround is printing or writing the last directory on exit and letting the shell cd into it. lf exposes the flags -print-last-dir and -last-dir-path for this purpose.

You can use one of the example lfcd wrapper shell scripts provided here: https://github.com/gokcehan/lf/tree/master/etc

Clone this wiki locally