- C 95.8%
- Shell 3.5%
- Makefile 0.6%
- Dockerfile 0.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| docs | ||
| src | ||
| tests | ||
| .dockerignore | ||
| .gitignore | ||
| CHANGELOG.md | ||
| compose.yaml | ||
| Dockerfile | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
Terminal File Manager
tfm is a terminal file manager that is easy to pick up and still does a lot. It is written
in C, has no library dependencies, and ships as a single small binary.
~/Pictures/holiday 1 2
raw/ Oct 28 09:14│ [ a preview of beach.jpg ]
beach.jpg 4.2M Oct 30 12:33│
* harbour.jpg 3.8M Oct 30 12:41│
itinerary.pdf 96K Oct 21 18:02│ 4032x3024 JPEG
-rw-r--r-- ana 4.2M 2026-10-30 12:33:10 1 selected 2/4 120G free
? Help Enter Open Space Select c Copy x Cut d Trash r Rename / Filter q Quit
Features
- Previews of images, videos, PDF pages, audio tags and cover art, archives, office documents, highlighted source code, folders and binary files.
- Real images in the terminal through kitty graphics, sixel or the iTerm2 protocol, and colored text blocks everywhere else, including over SSH and inside tmux.
- Nothing to memorize. The main keys stay on screen,
:searches every command,?lists every key, and right click opens a menu. - Safe by default.
duses the system trash anduundoes it. Copies are written to a temporary file first, so a cancelled or failed copy never leaves half a file behind. - Background jobs with progress for copy, move, delete, compress and extract.
- Fast finding: filter as you type, recursive name search, and search inside files.
- Tabs, bookmarks, recent folders, bulk rename in your editor, natural sorting, folder sizes, permissions, mouse support and automatic refresh.
Install
You need a C compiler and make. No libraries are required.
git clone https://git.turbotux.xyz/michanical/Terminal_FileManager.git
cd Terminal_FileManager
make
sudo make install
make install honors PREFIX and DESTDIR. To remove it again, run sudo make uninstall.
On the BSDs, use gmake or make; both understand the Makefile. For a static binary on Alpine
Linux:
apk add build-base
make LDFLAGS=-static
| System | Status |
|---|---|
| Linux with glibc | Tested |
| Alpine Linux with musl, static binary | Tested |
| FreeBSD, NetBSD, OpenBSD | Compiles and links; not yet run on real systems |
| macOS | Compiles and links; not yet run on a real system |
Preview tools
tfm finds these at run time. Everything else works without them, and the preview pane
tells you what to install when something is missing. tfm --doctor shows what it found.
| Preview | Tools |
|---|---|
| Images | ImageMagick or ffmpeg |
| Video, audio tags and cover art | ffmpeg |
poppler-utils (pdftoppm, pdfinfo, pdftotext) or mupdf-tools |
|
| Archives | tar, unzip, bsdtar or 7-Zip |
| Office documents, EPUB | pandoc |
| Code highlighting | bat or highlight |
| File descriptions | file |
# Fedora
sudo dnf install ImageMagick ffmpeg-free poppler-utils bat file unzip
# Debian, Ubuntu
sudo apt install imagemagick ffmpeg poppler-utils bat file unzip
# Alpine
sudo apk add imagemagick ffmpeg poppler-utils bat file unzip
# FreeBSD
sudo pkg install ImageMagick7 ffmpeg poppler-utils bat
# macOS
brew install imagemagick ffmpeg poppler bat
Usage
tfm # the current folder
tfm ~/Downloads # a folder
tfm ~/notes/todo.md # a folder, with the cursor on this file
| Key | Action | Key | Action |
|---|---|---|---|
Arrows, hjkl |
Move, enter, go back | / |
Filter this folder |
Enter |
Open | f / F |
Find names / text in files |
Space |
Select | w |
Show a search result in its folder |
a / A |
Select all / invert | s |
Sort |
c x v |
Copy, cut, paste | . |
Show hidden files |
d / D |
Trash / delete permanently | p / P |
Toggle / maximize preview |
u |
Undo trash or rename | J K |
Scroll the preview |
r |
Rename, or bulk rename a selection | [ ] |
Previous / next PDF page |
n |
New file, or folder with a trailing / |
Ctrl-L |
Go to a path, with Tab completion |
e / o |
Edit / open with | b / B |
Bookmarks / bookmark this folder |
i / m |
Properties / permissions | R / T |
Recent folders / trash |
z / Z |
Compress / extract | t Tab 1-9 |
New, next and numbered tabs |
y |
Copy path to the clipboard | ! |
Open a shell here |
S |
Measure folder sizes | q |
Quit |
Enter opens text in $VISUAL or $EDITOR. Other files use xdg-open or open in a
graphical session.
Stay in the last folder after quitting
Add this to your shell startup file, then start it with tm:
tm() {
cd_file="$(mktemp)"
tfm --cd-file "$cd_file" "$@"
cd "$(cat "$cd_file")" || true
rm -f "$cd_file"
}
Configuration
Settings live in ~/.config/tfm/config. docs/config.example lists all
of them.
show_hidden = yes
sort = mtime
image_backend = auto
open.pdf = & zathura
bind.ctrl-t = new_tab
open.<extension> chooses a program for a file type, and a leading & runs it in the
background. bind.<key> assigns a key to an action; the action names are the identifiers in the
table at the end of src/actions.c, such as new_tab, quit, trash or
find_text.
Inside tmux, automatic detection uses colored blocks, because tmux can claim sixel support even
when the outer terminal cannot draw it. Set image_backend = sixel if your terminal can.
Development
make # build
make test # unit tests, then end-to-end tests through tmux
make lint # build everything with warnings as errors
make sanitize # build with AddressSanitizer and UBSan; run the tests afterwards
make clean
tests/unit_tests.c covers the logic. tests/e2e.sh drives the real program through tmux and
checks both the screen and the file system. It is skipped when tmux is missing.
The program is a single-threaded select() loop, and everything slow runs in a forked child:
| File | Purpose |
|---|---|
src/term.c |
Raw mode, key decoding, cell buffer, terminal detection |
src/app.c, src/ui.c, src/widgets.c |
Event loop, drawing, prompts and menus |
src/actions.c |
Every command and its keys |
src/dir.c, src/filetype.c, src/text.c |
Listings, file classification, UTF-8 and sorting |
src/ops.c, src/trash.c, src/search.c |
Background jobs, trash, recursive search |
src/preview.c, src/preview_worker.c |
Preview cache and the child that produces previews |
src/raster.c, src/gfx.c, src/styled.c |
Image scaling, graphics protocols, colored text |
A few decisions are worth knowing before changing things:
- There is no ncurses dependency. Image protocols need direct control of the terminal, and this keeps the build free of libraries on every platform.
- Images are decoded by external tools in a child process that can be killed. Previewing a hostile file never parses it inside the main program.
- File names are untrusted. All text reaches the screen through the cell buffer, which replaces control characters, so a file name cannot send escape sequences to the terminal.
select()is used instead ofpoll(), becausepoll()does not work on terminal devices on macOS.
Docker
The image is built on Alpine and includes the preview tools. It mounts the current folder, or
TFM_ROOT if set, at /data.
docker compose run --rm tfm
TFM_ROOT=~/Pictures docker compose run --rm tfm
License
MIT. See LICENSE.