added opener script support
This commit is contained in:
+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
|
||||
|
||||
|
||||
@@ -679,6 +679,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