Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b729ffe8a | ||
|
|
25a329aba9 |
+26
-1
@@ -87,11 +87,34 @@ 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 entry count
|
||||
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
|
||||
---------------
|
||||
r Rename selected entry
|
||||
@@ -182,4 +205,6 @@ 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
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
# sfm - Simple File Manager in POSIX sh
|
||||
# sfm - Simple File Manager in POSIX sh (flicker-free)
|
||||
# version 0.4
|
||||
|
||||
# --- terminal control ---
|
||||
tput_cmd() { command -v tput >/dev/null 2>&1 && tput "$@"; }
|
||||
@@ -456,10 +457,36 @@ draw_preview() {
|
||||
|
||||
case "$entry" in
|
||||
*/)
|
||||
# directory: show entry count
|
||||
_dc=$(ls -1 "$_path" 2>/dev/null | wc -l | tr -d '[:space:]')
|
||||
goto 2 "$_px"
|
||||
printf '%s[dir] %s items%s' "${CYAN}" "${_dc}" "${RESET}"
|
||||
# directory: list contents
|
||||
_max_lines=$((_rows - 3))
|
||||
_pr=2
|
||||
for _de in "$_path"/*/; do
|
||||
[ "$_pr" -gt $((_rows - 1)) ] && break
|
||||
[ -d "$_de" ] || continue
|
||||
_dn="${_de%/}"; _dn="${_dn##*/}"
|
||||
[ "$_dn" = "*" ] && continue
|
||||
_dl=" ${_dn}/"
|
||||
[ "${#_dl}" -gt "$((_pw - 1))" ] && _dl="$(printf '%s' "$_dl" | cut -c1-$((_pw-2)))~"
|
||||
goto "$_pr" "$_px"
|
||||
printf '%s%s%s' "${GREEN}${BOLD}" "$_dl" "${RESET}"
|
||||
_pr=$((_pr + 1))
|
||||
done
|
||||
for _fe in "$_path"/*; do
|
||||
[ "$_pr" -gt $((_rows - 1)) ] && break
|
||||
[ -e "$_fe" ] || continue
|
||||
[ -d "$_fe" ] && continue
|
||||
_fn="${_fe##*/}"
|
||||
[ "$_fn" = "*" ] && continue
|
||||
_fl=" ${_fn}"
|
||||
[ "${#_fl}" -gt "$((_pw - 1))" ] && _fl="$(printf '%s' "$_fl" | cut -c1-$((_pw-2)))~"
|
||||
goto "$_pr" "$_px"
|
||||
printf '%s%s%s' "${WHITE}" "$_fl" "${RESET}"
|
||||
_pr=$((_pr + 1))
|
||||
done
|
||||
if [ "$_pr" -eq 2 ]; then
|
||||
goto 2 "$_px"
|
||||
printf '%s(empty)%s' "${WHITE}" "${RESET}"
|
||||
fi
|
||||
;;
|
||||
*@)
|
||||
# symlink
|
||||
@@ -679,6 +706,14 @@ _run_gui() { "$@" >/dev/null 2>&1 & }
|
||||
|
||||
open_file() {
|
||||
_f="$1"
|
||||
|
||||
# use user opener script if it exists and is executable
|
||||
_opener="${XDG_CONFIG_HOME:-$HOME/.config}/sfm/opener"
|
||||
if [ -x "$_opener" ]; then
|
||||
"$_opener" "$_f"
|
||||
return
|
||||
fi
|
||||
|
||||
_ext="${_f##*.}"
|
||||
_ext=$(printf '%s' "$_ext" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user