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

Install and run

Pre-requisites and installation

Pre-requisites:

  • absolutely required: fzf and fish
  • the :help feature: bat and less
  • filetype helper: 7z, atool (aunpack, apack), bat, iconv, lynx, mediainfo, pdftotext, unoconv, unrar, and zip/unzip
  • default/sample external commands: vim, git, perl, fd, etc., but those commands are yours to add/change/delete anyway.

Clone the repo and run ./install-fzfm. It copies the defaults and the modules. The modules get overwritten, but the defaults may contain your own customisations, so it pops up a vimdiff window for you to selectively copy anything the new version has, without blindly overwriting all your stuff.

Then we copy the main script. By default we put it in $HOME/bin and call it a day!

I’m too lazy to write a system-wide install, and mess with sudo, etc. It’s just a single script, so you can do that yourself if that is what you want.

Command line

First, the special option -., if specified, is processed. This makes fzfm show hidden files by default. This option must come first due to a technical limitation1. What I do is alias fm to fzfm and fmd to fzfm -.2.

Next, there are 3 possible options:

  • -m mode to directly go into a mode; e.g., fzfm -m git
  • -c 'some view command' to set the view command directly.
  • -p 'some preview command' to set the preview command. This becomes especially useful in some cases; see the examples below.

Some examples:

fzfm -c 'du -sk *|sort -rn|cut -f2'     # sort descending by disk usage
fzfm -c 'fd -e pl -e pm'                # only look at perl programs in the tree
fzfm -c 'rg -l pattern' -p 'rg -C5 --color=always pattern {}'
# only look at files containing "pattern", then in the preview show the matched lines with context

TIP: Setting up useful combinations of view+preview is the whole point of “modes”, as well as some of the non-mode commands (:c – sort by descending ctime, :cr – same, recursively, and :rg pattern, which does essentially what the 3rd example above does, with the added twist that if you TAB-select some entries it’ll only search those. For frequently used combinations, you can setup your own in cmd_hist

Notes:

  • The -m option cannot be used with the other two.
  • The view and preview commands need to be in fish syntax. For simple commands and redirection/pipes there is no difference, as you can see in the examples; it’s only if you get into if/then/else and such that it becomes a problem.

Finally, the arguments, if any, are resolved to real paths (especially, relative paths are made absolute).

  1. fzfm: Sets PWD, START_DIR and ALT_DIR all the same.
  2. fzfm dir: Does a cd to dir, then same as previous usage.
  3. fzfm dir1 dir2: Does a cd to dir1, sets PWD and START_DIR to dir1, sets ALT_DIR to dir2
  4. fzfm dir1 file: (experimental) modifies usage #2 as follows:
    • “file” should be a file at the top level of “dir1”
    • The cursor will be placed at that file on startup
    • Otherwise it’s the same as usage #2
  5. fzfm dir1 file dir2: ditto, for usage #3.

Tip: here is how to enable hidden files.

Directories

fzfm has 3 directories it always know about.

  • CWD: (no explanation needed)
  • START_DIR: the directory it was started from.
  • ALT_DIR: an alternate directory that helps us do some things that a single pane file manager normally cannot.

fzfm will always show you the names of these three at the top so there’s no confusion.

Builtin (internal) hotkeys

There are very few builtin actions, i.e., whose hotkeys cannot be changed.

  • fzf standard keys: TAB to multi-select, Ctrl-C to exit, ctrl-a to toggle “select all”.

  • alt-s to shell out (uses $SHELL).

  • ENTER on a directory to cd to it.

  • ENTER on a file, or after multi-selecting several files, to “open” all of them. Specifically, fzfm:

    • Opens each non-text file using xdg-open (one at a time)
    • Then opens all text files in one go using $EDITOR
  • ctrl-r and ctrl-v are special feature keys which need their own sections: “Running commands” and “Changing the view”.

Basic/important navigation keys

These used to be “builtin” (see previous section), but are now not. You can change the key assignments if you wish, and even the behaviour (details below):

  • alt-c to pick a directory to cd to

  • ctrl-t to select several files across the tree (i.e., can be from different subdirectories), and show only those in the view.

  • alt-f: pick a file, and cd to its directory. Useful if you remember the filename (or parts of it) better than the directory it lives in. Or the filename is easier to type uniquely.

Notes on alt-c, ctrl-t, and alt-f

  • alt-c and ctrl-t perform the same function you’re familiar with if you use fzf’s standard keybinds in your shell
    • Think of alt-f as a cross between those two :)
  • By default, they use fd -td and fd -tf, respectively. Pick an item and hit enter, and the “cd” happens.
  • If the query field is non-empty, it is used to pre-filter the list, which somehow seems “cooler” than typing in the query after the list loads!
  • If the query starts with a “.”, then
    • the . is stripped, and
    • the fd becomes fd -H --no-ignore-vcs, so hidden and vcs-ignored files also show up, but you can modify the code quite easily to change that to, say -HI instead.
  • Next, if the query starts with a “-a”, “-m”, “-c”, or “-s”, then this is stripped, and the output of the previous command is sorted by atime, mtime, ctime, and size, respectively. This is very useful if you want to see all the PDFs in a directory, but newest first.
    • This only applies to ctrl-t (doesn’t make sense for the other two).


  1. Fish’s argparse doesn’t like non-alphanumeric options, so we have to get that out of the way :-) ↩

  2. Well, I say “alias” but in fish it’s an “abbreviation”. ↩