- Managing files in the terminal
Why?
- easier on my wrists to use keyboard rather than mouse
- useful to have a CLI alternative to Finder if SSH-ing into a Mac remotely
- I do this with my home media server, which is a Mac mini with a bunch of files on it
Useful commands
vifm
β open Vifm to the folders it was open to when it was last closedvifm . .
β open the current folder in two panesTAB
orSPACE
- switch panes- Find files in current directory:
/REGEX_PATTERN
β search forward (down) in list?REGEX_PATTERN
β search backward (up) in listENTER
β select all results and jump to first occurrencen
β jump to next occurence (relative to search direction)N
β jump to previous occurrence (relative to search direction)ESC
β cancel search and deselect files
- Select and deselect files:
t
β select or unselect (tag) the current filev
+j
/k
β select a continuous group of filesENTER
to save selection + return to normal mode (can uset
to add other files to the selection)
ESC
or:noh
β clear selection in current pane/REGEX_PATTERN
to search forward +n
to go to next occurence +t
to select it
- Copy, move or delete selected file(s):
:move[?!] [ &]
or:m[?!] [ &]
β move selected files to directory in other pane- or:
Y
oryy
+ navigate to a different folder +P
- or:
:copy[?!] [ &]
or:co[?!] [ &]
β copy selected files to directory in other pane- or:
Y
oryy
+ navigate to a different folder +p
- or:
?
β prompt for destination file names in an editor!
β force overwrite&
β run command in background (unblocks UI)
- Delete selected files:
:delete[?!] [ &]
or:d[?!] [ &]
β move selected files to trash&
β run command in background (unblocks UI)
- or:
dd
- Cancellable copying, moving and deleting (blocks UI):
- select a file (or files) +
dd
- deletes file(s)
- select a file (or files) +
- Background copying, moving and deleting (doesnβt block UI; canβt be cancelled):
- select a file (or files) +
:delete
or:d
β deletes file(s)
- select a file (or files) +
- Create a directory:
:mkdir[!] dir
β creates a directory nameddir
relative to the current directory;!
creates subfolders as needed; names containing spaces need to be surrounded by""
- Rename a file or directory:
:rename
β without an argument, opens the selected file or directory name(s) in an editor (where they can be edited using vim keybindings); exitnvim
editor withZZ
:rename[!] file
β renames the selected file or directory tofile
;!
overwrites existing files; names containing spaces need to be surrounded by `""cw
β edit file or directory name(s) (includes file extension)cW
β edit file or directory name(s) (excludes file extension)
:jobs
β view background jobs;dd
to cancel;ESC
to exit:empty
- emptiesvifm
βs trash (use system trash by following these instructions):restore
β restore a file from the trash (~/.local/share/vifm/Trash)za
- toggle visibility of dot filesu
β undo last changeCtrl-R
β redo last changega
β update size shown next to selected directory name(s)- uses cached directory sizes when possible for better performance
gA
β likega
, but forces recalculation:β¬οΈ
β scroll through recent commands;ENTER
to run command againCtrl-G
β show a dialog with detailed information about the selected file%s/pattern/string/[flags]
β substitute instances of pattern in file with string; flag options:g
β replace all occurrences in the filei
β ignore caseI
β donβt ignore case
:cd -
β change to the previous directory:tree
β show a tree view of the current directory (to reveal all nested files and folders)- then use
/
(search) or=
(filter) to find files or directories at any depth - see: Find files in subfolders Β· Issue Β· vifm/vifm
h
at top level node orgh
at any level will leave the tree view
- then use
:touch
β create a new file
When to run commands in background
- when copying, moving or deleting files on an external volume
- why?
- copy, move and delete operations are quick on the local hard drive
- however, copy, move and delete operations on external volumes (e.g. a USB-connected external hard drive) can take awhile to complete
- if you copy, move or delete files and folders in the usual way, the UI will freeze/hang until the operation completes
- depending on the size of the files youβre modifying, that can take minutes or hours
- running those commands in the background instead will allow you to continue managing other files while those operations complete
:j
or:jobs
: view a list of background jobs in progressdd
: cancel the selected job(s)r
: reload the:jobs
list
Useful configuration
- how to customize configβ¦
- default config works fine
- my recommended config adjustments
sort
- ignore case when sorting files in a directory
- maybe donβt show all directories above all filesβ¦? weird in general but useful for my use case of updating show files
- maybe apply this myself but donβt recommend it? or call it out as optional?
- other config options
- Configuration model - Vifm Wiki
- Syntax highlighting file preview with
bat
(see my dotfiles) - Add custom nerd font file and folder icons using β¦ (see my dotfiles)