mirror of
https://github.com/dylanaraps/shfm.git
synced 2026-10-02 05:42:58 +07:00
114 lines
2.3 KiB
Plaintext
114 lines
2.3 KiB
Plaintext
shfm [wip]
|
|
________________________________________________________________________________
|
|
|
|
wip file manager written in posix shell
|
|
|
|
|
|
features
|
|
________________________________________________________________________________
|
|
|
|
* really nice escape sequence handling for keys which emit '\033[<stuff>'. Not
|
|
based on read timeouts. Based on tracking position within sequences.
|
|
|
|
* no dependencies other than a POSIX shell and POSIX (printf, dd, [ and stty)
|
|
|
|
* movement uses vim-like keybinds (hjkl).
|
|
|
|
|
|
todo
|
|
________________________________________________________________________________
|
|
|
|
- [x] scrolling is torture.
|
|
- [x] stop redrawing whole screen on key press.
|
|
- [x] store list somehow.
|
|
- [ ] search
|
|
- [ ] prompts
|
|
- [x] opener
|
|
- [x] resize
|
|
|
|
|
|
keybinds
|
|
________________________________________________________________________________
|
|
|
|
j - down
|
|
k - up
|
|
l - open file or directory
|
|
h - go up level
|
|
g - go to top
|
|
G - go to bottom
|
|
q - quit
|
|
|
|
|
|
opener
|
|
________________________________________________________________________________
|
|
|
|
opening files in different applications (based on mime-type or file extension)
|
|
can be achieved via an environment variable (SHFM_OPENER) set to the location of
|
|
a small external script. The default for all files will be '$EDITOR' (and if
|
|
that is unset, 'vi').
|
|
|
|
The script receives a single argument, the full path to the selected file.
|
|
The opener script is also useful on the command-line.
|
|
|
|
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
|