Skip to content
suewonjp edited this page Jun 13, 2017 · 3 revisions

lfs - Select a path from results returned by lf or lfi

✔️ General Usages

Most of time, lf or lfi will return multiple paths and you may need only one particular path from that returned list.

lfs will help you when you want to pick just one particular path.

  1. lfs
    • Will list all the paths returned by previous call of lf or lfi
  2. lfs [index]
    • Will select a path denoted by [index] from the paths found by previous call of lf or lfi
    • [index] starts from 0 not 1; Thus lfs 0 will select the first path from the list
    • [index] can be a negative value
      • e.g) lfs -1 will select the last path from the list
  3. lfs [index] +
    • Same as lfs [index] except that the selected path will be copied to the system clipboard
    • This is useful when you want to use that selected path for another application such as a text editor or file explorer, etc.
    • But ability to copy path to system clipboard requires you have installed system clipboard utility on your system in advance
    • Read the section below for more detail
  4. lfs --help
    • Will show help message

See also lff

✔️ Accessing System Clipboard from Command Line

lfs (for the 3rd usage above) requires a clipboard command line utility to copy a selected path to the system clipboard.

Systems like OS X and Windows Cygwin have such utility shipped by default, so + notation with lfs or lff will work like a charm.

However, on some systems, especially Linux or Unix, you may need to manually install such utility.

Fortunately, popular tools such as xsel and xclip are easy to install.
Installing either of xsel or xclip is recommended in order for lfs or lff to fully work on Linux or Unix.

Refer to this for further discussion.

✔️ Examples

$ lf --

files/empty.txt
files/folder 0/empty.txt
files/folder 0/folder 2/empty.txt
files/folder 0/foo.txt
files/folder 1/bar.txt

$ lfs

files/empty.txt
files/folder 0/empty.txt
files/folder 0/folder 2/empty.txt
files/folder 0/foo.txt
files/folder 1/bar.txt

$ lfs 0

files/empty.txt

$ lfs 2

files/folder 0/folder 2/empty.txt

$ lfs -1

files/folder 1/bar.txt

$ lfs 1 +
files/folder 0/empty.txt ## Now this path has been copied to the system clipboard...

✔️ About Path List ( Returned By lf Or lfi )

  • The current list can be printed out by simply executing lfs or lff without a parameter
  • This list is shared only within the same shell session.
  • Also the list is maintained only in memory; It's not persisted on disk storage.
  • Everytime you run either of the following commands, the list will be overwritten.