Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Collapsing a list

Let’s say we’re looking into all the pieces of gitolite related to “perms”. Running rg -l perms, or anything similar, will get you a flat list of files. We’d like to see those collapsed into a tree.

In effect, it’s like looking at a subset of the tree.

The demo below shows this for the “perms” example, but any “view” that results in showing files from all over the directory can be useful to collapse for easier understanding and navigation. For example, if you’re in your mp3 directory, you can focus on just the longest tracks by using :!set view_cmd "fd -tf -S +50M" (or whatever), and then collapse that list as shown in the demo.

And the code for this is, other than boilerplate/housekeeping, is basically 3 lines:

    eval $_fm_coll_source_view_cmd | path filter -f | sed -e 's/^\.\///' | rg / | cut -f1 -d/ | sort -u | xargs_ls
    echo
    # top level files
    eval $_fm_coll_source_view_cmd | path filter -f | sed -e 's/^\.\///' | rg -v / | xargs_ls
    echo
    # rest of the files
    eval $_fm_coll_source_view_cmd | path filter -f | sed -e 's/^\.\///' | rg / | xargs_ls