A lightweight, terminal-based file manager with a vim-inspired
key layout
- C++ 61.9%
- Shell 32.6%
- Roff 4.6%
- Makefile 0.9%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| LICENSE | ||
| Makefile | ||
| README | ||
| sfm.1 | ||
| sfm.cpp | ||
| sfm.sh | ||
sfm - Simple File Manager
==========================
DESCRIPTION
-----------
sfm is a lightweight, terminal-based file manager with a vim-inspired
key layout. The primary version is a fast C++ binary that works with
both ncurses and netbsd-curses. A portable POSIX sh version (sfm.sh) is
also included, requiring only standard Unix tools (ls, awk, tput, stty,
mv, cp, rm).
REQUIREMENTS
------------
C++ version (sfm):
- A curses library: ncursesw, ncurses, or netbsd-curses (libcurses)
- A C++17 compiler (g++ or compatible)
- Optional: libsixel (for image previews; loaded at runtime, so it is
not needed to build sfm)
Shell version (sfm.sh):
- A POSIX-compatible shell (sh, dash, bash, etc.)
- Standard Unix tools: ls, awk, tput, stty, cp, mv, rm, mkdir, touch
Both versions:
- Optional: wl-copy / xclip / xsel / pbcopy (for clipboard support)
- Optional: mpv, vlc, feh, zathura, etc. (for smart file opening)
- Optional: readlink (for symlink display)
- Optional: file (for MIME type detection)
- Optional: less (for viewing text files)
INSTALLATION
------------
Using make (recommended):
make install
This builds the C++ binary and installs both sfm (C++ binary)
and sfm.sh (shell script) to /usr/local/bin by default.
To change the prefix:
make install PREFIX=/usr
To uninstall:
make uninstall
Manual installation (shell version only):
cp sfm.sh /usr/local/bin/sfm.sh
chmod +x /usr/local/bin/sfm.sh
USAGE
-----
sfm [path]
If no path is given, sfm opens in the current directory.
Examples:
sfm # open in current directory
sfm /mnt/data # open at a specific path
sfm ~ # open home directory
sfm .. # open parent directory
NAVIGATION
----------
j / k or up/down arrows Move up / down
h or left arrow Go to parent directory
l or right arrow / enter Open file or enter directory
g Jump to top of list
G Jump to bottom of list
~ Go to home directory
` (backtick) Jump to previous directory
SEARCH & FILTER
---------------
/ Enter search mode (filters listing as you type)
esc Clear filter and exit search mode
enter Exit search mode but keep filter active
DISPLAY TOGGLES
---------------
. Toggle hidden files (dotfiles)
T Toggle size/date detail column
P Toggle preview pane (right side)
s Cycle sort mode: name -> size -> date
i Show file info popup (type, perms, owner, size, date)
R Refresh current directory listing
PREVIEW PANE
------------
Press P to toggle the preview pane on the right side of the screen.
The list pane takes the left half, preview takes the right half.
Text files Shows file contents line by line
Directories Shows directory contents
Symlinks Shows link target
Images Shows the image (C++ version, when libsixel is
installed and the terminal supports sixel, e.g.
foot, xterm, WezTerm or mlterm)
Binary files Shows file size
Image previews cover the formats libsixel can read (PNG, JPEG, GIF,
BMP, TGA, PSD, HDR, PNM, sixel, and more if libsixel was built with
gdk-pixbuf or GD). At startup sfm looks for libsixel and, if found,
asks the terminal whether it supports sixel; set SFM_SIXEL=1 to force it on or SFM_SIXEL=0 to turn it off.
CUSTOM OPENER
-------------
sfm checks for a user-defined opener script at:
~/.config/sfm/opener
If the file exists and is executable, sfm passes the selected file
path to it instead of using the built-in smart opener. Example:
#!/bin/sh
case "$1" in
*.jpg|*.jpeg) imv "$1" ;;
*.mp4) mpv "$1" ;;
*.html|*.pdf) firefox "$1" ;;
*) echo "no program set for this file type" ;;
esac
Make it executable: chmod +x ~/.config/sfm/opener
If the opener script does not exist, sfm falls back to its built-in
smart opener automatically.
FILE OPERATIONS
---------------
r Rename selected entry
m Make new directory
n New empty file
d Delete (single or selection)
u Move to trash (safe delete; works on selection)
U Open trash directory
e Edit in $EDITOR (or vi)
o Open with custom program
CLIPBOARD
---------
y Yank / copy (works on multi-selection)
x Cut (works on multi-selection)
p Paste into current directory
c Copy full path of selected entry to system clipboard
MULTI-SELECT
------------
space Toggle multi-select on current entry (cursor advances)
a Select all / deselect all
BOOKMARKS
---------
b Open bookmark picker (j/k navigate, enter jump, d remove)
B Bookmark current directory (press again to remove)
Bookmarks are saved to: ~/.config/sfm/bookmarks
SHELL & UTILITIES
-----------------
! Drop into $SHELL in current directory (type "exit" to return)
TEXT PROMPTS
------------
Prompts (rename, new file, mkdir, jump, find, open-with) accept UTF-8.
left/right Move by one character
ctrl-a/ctrl-e Start / end of line
ctrl-u Clear the line
ctrl-k Delete to end of line
ctrl-w Delete the previous word
backspace Delete the previous character
esc Cancel
Long input scrolls horizontally.
CONFIRM DIALOGS
---------------
y / n Answer directly
h/l or arrows Move between [Yes] and [No], enter to pick
esc or q Cancel
HELP
----
? Show keyboard shortcuts overlay. The overlay lays its
sections out in as many columns as the terminal fits;
if it is still too short, j/k (g/G) scroll it.
QUIT
----
q Quit sfm
STATUS BAR INDICATORS
---------------------
[hidden] Hidden files are visible
[sort:size] Active sort mode (size or date; name is default)
[copy] A file is in the clipboard (copy mode)
[cut] A file is in the clipboard (cut mode)
[sel:N] N items are currently selected
[details] Size/date column is visible
SMART FILE OPENER
-----------------
When you open a file, sfm detects the file type by extension and
MIME type, then picks an appropriate program automatically:
Text / code less
Images imv, feh, sxiv, eog, gimp
Video mpv, vlc, mplayer, totem
Audio mpv, vlc, cmus, mocp
PDF zathura, evince, okular, mupdf
Office docs libreoffice
Archives atool / bsdtar (lists contents in pager)
Falls back to xdg-open, open (macOS), or less if nothing matches.
Use 'e' to edit a file in $EDITOR, or 'o' to manually specify any
program.
TRASH
-----
Files deleted with 'u' are moved to:
~/.local/share/sfm-trash/
Files are prefixed with a timestamp: YYYYMMDD_HHMMSS_filename
Use U to browse the trash directory. To restore a file, rename it
(press r) to remove the timestamp prefix, then cut (x) and paste (p)
it back to the desired location.
DATA FILES
----------
~/.config/sfm/bookmarks Saved bookmarks (one path per line)
~/.config/sfm/opener Custom file opener script (optional)
~/.local/share/sfm-trash/ Trashed files