25 Commits
Author SHA1 Message Date
emmett1 0504dec9c7 info mode now shows info box 2026-05-31 00:08:51 +08:00
emmett1 f85d1af121 fix new directory mode text 2026-05-31 00:00:48 +08:00
emmett1 308637d874 fix new file mode text 2026-05-30 23:59:28 +08:00
emmett1 aaf7fd829d improve rename mode 2026-05-30 23:57:36 +08:00
emmett1 8db9a070b7 yes no box for file deletion confirmation 2026-05-30 23:51:26 +08:00
emmett1 bed888c3c3 fix and updates 2026-05-29 11:32:58 +08:00
emmett1 7c2f21d8ec updated man page 2026-04-11 09:05:45 +08:00
emmett1 938955120b fix page down, page up and del key, added del key to delete function 2026-04-11 08:57:44 +08:00
emmett1 f374506215 update 2026-04-11 08:51:01 +08:00
emmett1 fe57971b91 removed extension colouring, and changed some colours 2026-04-11 02:11:23 +08:00
emmett1 2f8d3e8d9e man page updated 2026-04-10 07:35:11 +08:00
emmett1 2a1f8fc0a5 add find function 2026-04-05 20:00:02 +08:00
emmett1 346ef7b7cb add jump to path function 2026-04-05 19:39:24 +08:00
emmett1 09f60a85ef add chmod +x and -x function 2026-04-05 19:33:56 +08:00
emmett1 32337e4cca show hidden files first when enabled hidden 2026-04-05 01:35:44 +08:00
emmett1 03df88a150 added man page 2026-04-01 00:35:31 +08:00
emmett1 54352d036c renamed README.txt to README 2026-04-01 00:35:04 +08:00
emmett1 6b729ffe8a updated panel mode 2026-03-28 07:54:42 +08:00
emmett1 25a329aba9 added opener script support 2026-03-28 00:08:08 +08:00
emmett1 6f9feaf9b4 updated README.txt 2026-03-16 00:44:07 +08:00
emmett1 fbc3227515 added preview function 2026-03-16 00:36:44 +08:00
emmett1 02a8adadc4 fix when browse into empty directory 2026-03-16 00:21:22 +08:00
emmett1 1e6fdd9e29 add function to run from target directory 2026-03-16 00:14:29 +08:00
emmett1 12c85202f9 fix double slash at directory name 2026-03-16 00:11:24 +08:00
emmett1 7f41df91f1 fix symlink show twice, one as symlink, one as directory 2026-03-15 23:58:18 +08:00
4 changed files with 1206 additions and 307 deletions
+8 -4
View File
@@ -15,17 +15,21 @@ all:
@echo "Run 'make install' to install." @echo "Run 'make install' to install."
install: install:
@echo "Installing sfm to $(BINDIR)/sfm ..." @echo "Installing sfm to $(DESTDIR)$(BINDIR)/sfm ..."
$(INSTALL) -d $(DESTDIR)$(BINDIR) $(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 sfm $(DESTDIR)$(BINDIR)/sfm $(INSTALL) -m 755 sfm $(DESTDIR)$(BINDIR)/sfm
@echo "Installing README to $(DOCDIR) ..." @echo "Installing man page to $(DESTDIR)$(MANDIR)/sfm.1 ..."
$(INSTALL) -d $(DESTDIR)$(MANDIR)
$(INSTALL) -m 644 sfm.1 $(DESTDIR)$(MANDIR)/sfm.1
@echo "Installing README to $(DESTDIR)$(DOCDIR)/README ..."
$(INSTALL) -d $(DESTDIR)$(DOCDIR) $(INSTALL) -d $(DESTDIR)$(DOCDIR)
$(INSTALL) -m 644 README.txt $(DESTDIR)$(DOCDIR)/README.txt $(INSTALL) -m 644 README $(DESTDIR)$(DOCDIR)/README
@echo "Done. Run 'sfm' to start." @echo "Done. Run 'sfm' to start, or 'man sfm' for help."
uninstall: uninstall:
@echo "Removing sfm ..." @echo "Removing sfm ..."
$(RM) $(DESTDIR)$(BINDIR)/sfm $(RM) $(DESTDIR)$(BINDIR)/sfm
$(RM) $(DESTDIR)$(MANDIR)/sfm.1
$(RM) -r $(DESTDIR)$(DOCDIR) $(RM) -r $(DESTDIR)$(DOCDIR)
@echo "Done." @echo "Done."
+45 -2
View File
@@ -17,6 +17,7 @@ REQUIREMENTS
- Optional: wl-copy / xclip / xsel / pbcopy (for clipboard support) - Optional: wl-copy / xclip / xsel / pbcopy (for clipboard support)
- Optional: mpv, vlc, feh, zathura, etc. (for smart file opening) - Optional: mpv, vlc, feh, zathura, etc. (for smart file opening)
- Optional: readlink (for symlink display) - Optional: readlink (for symlink display)
- Optional: file (for MIME type detection)
INSTALLATION INSTALLATION
@@ -41,9 +42,15 @@ Manual installation:
USAGE USAGE
----- -----
sfm sfm [path]
sfm will opens in the current directory. 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 NAVIGATION
@@ -68,11 +75,46 @@ DISPLAY TOGGLES
--------------- ---------------
. Toggle hidden files (dotfiles) . Toggle hidden files (dotfiles)
T Toggle size/date detail column T Toggle size/date detail column
P Toggle preview pane (right side)
s Cycle sort mode: name -> size -> date s Cycle sort mode: name -> size -> date
i Show file info (permissions, size, date) in status bar i Show file info (permissions, size, date) in status bar
R Refresh current directory listing 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
Binary files Shows file size
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 FILE OPERATIONS
--------------- ---------------
r Rename selected entry r Rename selected entry
@@ -163,5 +205,6 @@ it back to the desired location.
DATA FILES DATA FILES
---------- ----------
~/.config/sfm/bookmarks Saved bookmarks (one path per line) ~/.config/sfm/bookmarks Saved bookmarks (one path per line)
~/.config/sfm/opener Custom file opener script (optional)
~/.local/share/sfm-trash/ Trashed files ~/.local/share/sfm-trash/ Trashed files
+728 -252
View File
File diff suppressed because it is too large Load Diff
+376
View File
@@ -0,0 +1,376 @@
.TH SFM 1 "2026-03-16" "0.4" "Simple File Manager"
.SH NAME
sfm \- Simple File Manager
.SH SYNOPSIS
.B sfm
.RI [ path ]
.SH DESCRIPTION
.B sfm
is a lightweight, terminal-based file manager written entirely in POSIX sh.
It runs in your terminal with no external dependencies beyond standard Unix
tools. Designed to be fast, flicker-free, and keyboard-driven with a
vim-inspired key layout.
If
.I path
is given, sfm opens that directory. Otherwise it opens in the current
working directory.
.SH KEY BINDINGS
.SS Navigation
.TP
.BR j ", " k " or " "up/down arrows"
Move cursor up or down.
.TP
.BR h " or " "left arrow"
Go to parent directory.
.TP
.BR l ", " "right arrow" ", or " enter
Open selected file or enter directory.
.TP
.B g
Jump to top of list.
.TP
.B G
Jump to bottom of list.
.TP
.B ~
Go to home directory.
.TP
.B \`
Jump to previous directory (toggle).
.TP
.B :
Prompt for a path to jump to directly. Supports
.B ~
expansion. Shows an error if the path does not exist. Press esc to cancel.
.TP
.B f
Find files recursively under the current directory. Opens an interactive
picker. Press j/k or arrows to navigate results, enter or l to jump to the
selected result, esc/q/h to close.
.SS Search and Filter
.TP
.B /
Enter search mode. The listing is filtered as you type.
.TP
.B esc
Clear filter and exit search mode.
.TP
.B enter
Exit search mode while keeping the current filter active.
.SS Display Toggles
.TP
.B .
Toggle hidden files (dotfiles). Hidden entries appear before regular
entries (hidden dirs, then regular dirs, then hidden files, then
regular files).
.TP
.B T
Toggle size/date detail column.
.TP
.B P
Toggle preview pane on the right side.
.TP
.B s
Cycle sort mode: name \-> size \-> date.
.TP
.B i
Show file info (permissions, size, date) in the status bar.
.TP
.B R
Refresh the current directory listing.
.SS File Operations
.TP
.B r
Rename selected entry. Press esc to cancel.
.TP
.B m
Create a new directory. Press esc to cancel.
.TP
.B n
Create a new empty file. Press esc to cancel.
.TP
.B d " or " del
Delete selected entry or all multi-selected entries.
Non-empty directories require a second confirmation.
.TP
.B u
Move selected entry to trash (safe delete).
.TP
.B U
Open the trash directory.
.TP
.B o
Open selected file with a custom program. Press esc to cancel.
.TP
.B +
Make the selected file executable
.RB ( "chmod +x" ).
.TP
.B \-
Remove execute permission from the selected file
.RB ( "chmod -x" ).
.SS Clipboard
.TP
.B y
Yank (copy) selected entry or all multi-selected entries.
.TP
.B x
Cut selected entry or all multi-selected entries.
.TP
.B p
Paste clipboard contents into the current directory.
Auto-renames on conflict by appending
.IR _copy .
.TP
.B c
Copy the full path of the selected entry to the system clipboard.
Requires
.BR wl-copy ", " xclip ", " xsel ", or " pbcopy .
.SS Multi-Select
.TP
.B space
Toggle multi-select on the current entry (cursor advances).
.TP
.B a
Select all entries / deselect all.
.PP
Multi-select works with
.BR y ", " x ", and " d .
.SS Bookmarks
.TP
.B b
Bookmark the current directory. Press again to remove it.
.TP
.B B
Open the bookmark picker.
Use j/k to navigate, enter to jump, esc to close.
.SS Other
.TP
.B !
Drop into
.B $SHELL
in the current directory. Type
.I exit
to return to sfm. The working directory is updated if you cd elsewhere
in the shell.
.TP
.B ?
Show the keyboard shortcuts help overlay.
.TP
.B q
Quit sfm.
.SH PREVIEW PANE
When the preview pane is enabled with
.BR P ,
the terminal is split into a left pane (file list) and a right pane
(preview). The preview shows:
.IP \(bu 2
.B Text files \-
file contents displayed line by line.
.IP \(bu 2
.B Directories \-
directory contents (subdirectories first, then files).
.IP \(bu 2
.B Symlinks \-
the link target path.
.IP \(bu 2
.B Binary files \-
file size.
.SH CUSTOM OPENER
.B sfm
checks for a user-defined opener script at:
.PP
.I ~/.config/sfm/opener
.PP
If the file exists and is executable, sfm passes the selected file path
to it as the first argument instead of using the built-in smart opener.
.PP
Example opener script:
.PP
.nf
#!/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
.fi
.PP
Make it executable with:
.B chmod +x ~/.config/sfm/opener
.PP
If the opener script does not exist, sfm falls back to its built-in
smart opener which detects file types by extension and MIME type.
.SH SMART FILE OPENER
When no custom opener is configured, sfm opens files using the first
available program for each file type:
.TP
.B Text / code
$EDITOR or vi.
.TP
.B Images
imv, feh, sxiv, eog, gimp.
.TP
.B Video
mpv, vlc, mplayer, totem.
.TP
.B Audio
mpv, vlc, cmus, mocp.
.TP
.B PDF
zathura, evince, okular, mupdf.
.TP
.B Office documents
libreoffice.
.TP
.B Archives
atool or bsdtar (lists contents in pager).
.PP
Falls back to xdg-open, open (macOS), or $EDITOR.
.SH FILE COLOURS
.TP
.B Green bold
Directories.
.TP
.B Red bold
Executables and broken symlinks.
.TP
.B Magenta
Images.
.TP
.B Magenta bold
Video files and valid symlinks.
.TP
.B Cyan bold
Audio files.
.TP
.B Red
Archives (zip, tar, gz, etc.).
.TP
.B Yellow
Documents (pdf, docx, etc.).
.TP
.B Green
Code and scripts (py, sh, rs, etc.).
.TP
.B Cyan
Config and data files (json, yaml, etc.).
.TP
.B White
Text, markdown, and all other files.
.SH STATUS BAR INDICATORS
.TP
.B [hidden]
Hidden (dot) files are currently visible.
.TP
.B [sort:size] or [sort:date]
Active sort mode. Not shown when sorting by name (default).
.TP
.B [copy] or [cut]
A file is stored in the clipboard.
.TP
.B [sel:N]
N items are currently multi-selected.
.TP
.B [details]
Size/date detail column is visible.
.SH TRASH
Files deleted with
.B u
are moved to:
.PP
.I ~/.local/share/sfm-trash/
.PP
Files are prefixed with a timestamp in the format
.IR YYYYMMDD_HHMMSS_filename .
Use
.B U
to browse the trash directory. To restore a file, rename it with
.B r
to remove the timestamp prefix, then cut with
.B x
and paste with
.B p
to the desired location.
.SH FILES
.TP
.I ~/.config/sfm/bookmarks
Saved bookmarks, one directory path per line.
.TP
.I ~/.config/sfm/opener
Custom file opener script (optional, must be executable).
.TP
.I ~/.local/share/sfm-trash/
Directory where trashed files are stored.
.SH ENVIRONMENT
.TP
.B EDITOR
Editor used to open text files when no custom opener is set.
.TP
.B SHELL
Shell used when dropping to the terminal with
.BR ! .
.TP
.B PAGER
Pager used when listing archive contents.
.TP
.B XDG_CONFIG_HOME
Base directory for sfm config files. Defaults to
.IR ~/.config .
.TP
.B XDG_DATA_HOME
Base directory for sfm data files (trash). Defaults to
.IR ~/.local/share .
.SH EXAMPLES
Open sfm in the current directory:
.PP
.nf
sfm
.fi
.PP
Open sfm at a specific path:
.PP
.nf
sfm /mnt/data
.fi
.PP
Use sfm as a cd wrapper (add to shell rc):
.PP
.nf
s() { cd "$(sfm)"; }
.fi
.SH AUTHORS
Emmett1 <me@emmett1.my> with help of AI.
.SH SEE ALSO
.BR find (1),
.BR ls (1),
.BR mv (1),
.BR cp (1),
.BR rm (1),
.BR chmod (1),
.BR vi (1)