shfm/README

119 lines
2.4 KiB
Plaintext
Raw Normal View History

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-03 22:41:34 +02:00
* Really nice escape sequence handling for keys which emit '\033[<stuff>'. Not
based on shitty read timeouts (can't do 'em anyway). Instead based on tracking
position within escape sequences.
2020-08-03 15:35:13 +02:00
2020-08-03 22:52:06 +02:00
* no dependencies other than a POSIX shell and POSIX (just printf, dd and stty)
2020-08-03 15:35:13 +02:00
2020-08-03 22:41:34 +02:00
* tiny?
2020-08-03 15:36:58 +02:00
2020-08-03 15:35:13 +02:00
todo
________________________________________________________________________________
2020-08-03 20:40:57 +02:00
- [x] scrolling is torture.
- [x] stop redrawing whole screen on key press.
- [x] store list somehow.
2020-08-03 15:35:13 +02:00
- [ ] search
- [ ] prompts
2020-08-03 22:33:13 +02:00
- [x] opener
- [x] resize
2020-08-03 22:41:34 +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 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