sfm

Simple File Manager
git clone git://git.emmett1.my/sfm.git
Log | Files | Refs | LICENSE

commit 1e6fdd9e29f77c955182920744c5c2be706eb3b0
parent 12c85202f92282e7c92c3295c01f494bcbe13a95
Author: emmett1 <emmett1.2miligrams@protonmail.com>
Date:   Mon, 16 Mar 2026 00:14:29 +0800

add function to run from target directory

Diffstat:
Msfm | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sfm b/sfm @@ -1,5 +1,6 @@ #!/bin/sh -# sfm - Simple File Manager in POSIX sh +# sfm - Simple File Manager in POSIX sh (flicker-free) +# version 0.3 # --- terminal control --- tput_cmd() { command -v tput >/dev/null 2>&1 && tput "$@"; } @@ -61,7 +62,11 @@ term_rows() { tput_cmd lines || echo 24; } term_cols() { tput_cmd cols || echo 80; } # --- state --- -CWD="$PWD"; CWD=$(cd "$CWD" 2>/dev/null && pwd) || CWD="/" +if [ -n "$1" ]; then + CWD=$(cd "$1" 2>/dev/null && pwd) || { printf 'sfm: %s: no such directory\n' "$1" >&2; exit 1; } +else + CWD=$(cd "$PWD" 2>/dev/null && pwd) || CWD="/" +fi SEL=0 OFFSET=0 PREV_SEL=0