Update 2024-10-24 00:06 OpenBSD/amd64-t14
This commit is contained in:
parent
de5b108398
commit
bcacac1029
21
.bin/nnn.sh
21
.bin/nnn.sh
@ -1,4 +1,4 @@
|
|||||||
#!/bin/ksh
|
#!/bin/ksh -x
|
||||||
|
|
||||||
f="$1"
|
f="$1"
|
||||||
|
|
||||||
@ -12,7 +12,6 @@ fi
|
|||||||
# SSH
|
# SSH
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
# SSH
|
|
||||||
if print "$f" | egrep -qi '^shell:|^ushell:|^cvs:|^home:';
|
if print "$f" | egrep -qi '^shell:|^ushell:|^cvs:|^home:';
|
||||||
then
|
then
|
||||||
_server=${f%%:*}
|
_server=${f%%:*}
|
||||||
@ -24,6 +23,7 @@ fi
|
|||||||
###################################################
|
###################################################
|
||||||
# TRY TO FIND MIME TYPE
|
# TRY TO FIND MIME TYPE
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
if print "$f" | egrep -qi '^http[s]{0,1}://';
|
if print "$f" | egrep -qi '^http[s]{0,1}://';
|
||||||
then
|
then
|
||||||
MIME="$(webmime "$f")"
|
MIME="$(webmime "$f")"
|
||||||
@ -45,13 +45,14 @@ fi
|
|||||||
###################################################
|
###################################################
|
||||||
# TRANSLATE MIME TYPES TO EXTENSIONS
|
# TRANSLATE MIME TYPES TO EXTENSIONS
|
||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
case "$MIME" in
|
case "$MIME" in
|
||||||
# full qualified
|
# full qualified
|
||||||
application/ogg) EXT=ogg; ;;
|
application/ogg) EXT=ogg; ;;
|
||||||
application/pdf) EXT=pdf; ;;
|
application/pdf) EXT=pdf; ;;
|
||||||
application/postscript) EXT=ps; ;;
|
application/postscript) EXT=ps; ;;
|
||||||
application/vnd.oasis.opendocument.*) EXT=docx; ;;
|
application/vnd.oasis.opendocument.*) EXT=docx; ;;
|
||||||
audio/mpeg) EXT=mpg; ;;
|
audio/mpeg) EXT=mp3; ;;
|
||||||
audio/midi) EXT=midi; ;;
|
audio/midi) EXT=midi; ;;
|
||||||
image/webp) EXT=webp; ;;
|
image/webp) EXT=webp; ;;
|
||||||
application/x-gzip) EXT=gz; ;;
|
application/x-gzip) EXT=gz; ;;
|
||||||
@ -72,7 +73,7 @@ case "$EXT" in
|
|||||||
docx) EXEC="libreoffice"; ;;
|
docx) EXEC="libreoffice"; ;;
|
||||||
flv) EXEC="mpv"; ;;
|
flv) EXEC="mpv"; ;;
|
||||||
m2ts) EXEC="mpv"; ;;
|
m2ts) EXEC="mpv"; ;;
|
||||||
mp3) EXEC_TERM="aplay"; ;;
|
mp3) EXEC="mpv"; ;;
|
||||||
mp4) EXEC="mpv"; ;;
|
mp4) EXEC="mpv"; ;;
|
||||||
out) EXEC="kdump -RTf"; ;;
|
out) EXEC="kdump -RTf"; ;;
|
||||||
sid) EXEC="sidplay"; ;;
|
sid) EXEC="sidplay"; ;;
|
||||||
@ -80,11 +81,19 @@ case "$EXT" in
|
|||||||
txt) EXEC="vim"; ;;
|
txt) EXEC="vim"; ;;
|
||||||
webm) EXEC="mpv"; ;;
|
webm) EXEC="mpv"; ;;
|
||||||
xlsx) EXEC="libreoffice"; ;;
|
xlsx) EXEC="libreoffice"; ;;
|
||||||
|
jpg) EXEC="nsxiv"; ;;
|
||||||
generic_text) EXEC="vim"; ;;
|
generic_text) EXEC="vim"; ;;
|
||||||
generic_video) EXEC="mpv"; ;;
|
generic_video) EXEC="mpv"; ;;
|
||||||
|
generic_image) EXEC="nsxiv"; EXEC_HTTP="$BROWSER"; ;;
|
||||||
generic_audio) EXEC="mpv"; ;;
|
generic_audio) EXEC="mpv"; ;;
|
||||||
esac
|
esac
|
||||||
echo "TYPE=$TYPE | MIME=$MIME | EXT=.$EXT | EXEC=$EXEC"
|
|
||||||
|
|
||||||
[ ! -z "$EXEC" ] && exec $EXEC "$f"
|
echo "TYPE=$TYPE | MIME=$MIME | EXT=$EXT | EXEC=$EXEC"
|
||||||
|
|
||||||
|
case "$TYPE" in
|
||||||
|
gopher) exec $EXEC_GOPHER "$f"; ;;
|
||||||
|
http) exec $EXEC_HTTP "$f"; ;;
|
||||||
|
file) exec $EXEC "$f"; ;;
|
||||||
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user