2020-08-03 15:50:11 +02:00
|
|
|
shfm [wip]
|
2020-08-03 15:30:38 +02:00
|
|
|
________________________________________________________________________________
|
|
|
|
|
|
|
|
wip file manager written in posix shell
|
|
|
|
|
2020-08-03 15:35:13 +02:00
|
|
|
|
|
|
|
features
|
|
|
|
________________________________________________________________________________
|
|
|
|
|
2020-08-04 00:23:27 +02:00
|
|
|
* no dependencies other than a POSIX shell + POSIX printf, dd and stty
|
|
|
|
* tiny
|
|
|
|
* single file
|
|
|
|
* no compilation needed
|
2020-08-03 15:36:58 +02:00
|
|
|
|
2020-08-03 15:35:13 +02:00
|
|
|
|
2020-08-03 15:38:13 +02:00
|
|
|
keybinds
|
|
|
|
________________________________________________________________________________
|
|
|
|
|
|
|
|
j - down
|
|
|
|
k - up
|
|
|
|
l - open file or directory
|
|
|
|
h - go up level
|
2020-08-03 22:00:36 +02:00
|
|
|
g - go to top
|
|
|
|
G - go to bottom
|
2020-08-03 15:38:13 +02:00
|
|
|
q - quit
|
2020-08-03 23:17:56 +02:00
|
|
|
: - cd to <input>
|
2020-08-03 23:27:28 +02:00
|
|
|
/ - search current directory *<input>*
|
2020-08-04 00:02:11 +02:00
|
|
|
- - go to last directory
|
|
|
|
~ - go home
|
|
|
|
! - spawn shell
|
2020-08-04 00:09:15 +02:00
|
|
|
. - toggle hidden files
|
2020-08-03 22:33:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
opener
|
|
|
|
________________________________________________________________________________
|
|
|
|
|
2020-08-03 22:37:58 +02:00
|
|
|
Opening files in different applications (based on mime-type or file extension)
|
2020-08-03 22:33:13 +02:00
|
|
|
can be achieved via an environment variable (SHFM_OPENER) set to the location of
|
2020-08-03 22:37:58 +02:00
|
|
|
a small external script. If unset, the default for all files is '$EDITOR' (and
|
|
|
|
if that is unset, 'vi').
|
2020-08-03 22:33:13 +02:00
|
|
|
|
|
|
|
The script receives a single argument, the full path to the selected file.
|
2020-08-03 22:36:48 +02:00
|
|
|
The opener script is also useful on the command-line. The environment variable
|
|
|
|
is set as follows.
|
|
|
|
|
|
|
|
export SHFM_OPENER=/path/to/script
|
2020-08-03 22:33:13 +02:00
|
|
|
|
|
|
|
Example scripts:
|
|
|
|
|
|
|
|
#!/bin/sh -e
|
|
|
|
#
|
|
|
|
# open file in application based on file extension
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
*.mp3|*.flac|*.wav)
|
|
|
|
mpv --no-video "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*.mp4|*.mkv|*.webm)
|
|
|
|
mpv "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*.png|*.gif||*.jpg|*.jpe|*.jpeg)
|
|
|
|
gimp "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*.html|*.pdf)
|
|
|
|
firefox "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
# all other files
|
|
|
|
*)
|
|
|
|
"${EDITOR:=vi}" "$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
#!/bin/sh -e
|
|
|
|
#
|
|
|
|
# open file in application based on mime-type
|
|
|
|
|
|
|
|
mime_type=$(file -bi)
|
|
|
|
|
|
|
|
case $mime_type in
|
|
|
|
audio/*)
|
|
|
|
mpv --no-video "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
video/*)
|
|
|
|
mpv "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
image/*)
|
|
|
|
gimp "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
text/html*|application/pdf*)
|
|
|
|
firefox "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
text/*|)
|
|
|
|
"${EDITOR:=vi}" "$1"
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
printf 'unknown mime-type %s\n' "$mime_type"
|
|
|
|
;;
|
|
|
|
esac
|