mirror of
https://github.com/jarun/nnn.git
synced 2025-01-26 02:36:36 +00:00
Added execute fallback to nuke
This commit is contained in:
parent
7b31a356d2
commit
4b4355c733
25
plugins/nuke
25
plugins/nuke
|
@ -21,9 +21,10 @@
|
||||||
# Guards against accidentally opening mime types like executables, shared libs etc.
|
# Guards against accidentally opening mime types like executables, shared libs etc.
|
||||||
#
|
#
|
||||||
# Tries to play 'file' (1st argument) in the following order:
|
# Tries to play 'file' (1st argument) in the following order:
|
||||||
# i. by extension
|
# 1. by extension
|
||||||
# ii. by mime (image, video, audio, pdf)
|
# 2. by mime (image, video, audio, pdf)
|
||||||
# iii. by mime (other file types)
|
# 3. by mime (other file types)
|
||||||
|
# 4. by mime (prompt and run executables)
|
||||||
#
|
#
|
||||||
# Modification tips:
|
# Modification tips:
|
||||||
# 1. Invokes CLI utilities by default. Set GUI to 1 to enable GUI apps.
|
# 1. Invokes CLI utilities by default. Set GUI to 1 to enable GUI apps.
|
||||||
|
@ -63,8 +64,9 @@
|
||||||
# 1. Adapt, test and enable all mimes
|
# 1. Adapt, test and enable all mimes
|
||||||
# 2. Clean-up the unnecessary exit codes
|
# 2. Clean-up the unnecessary exit codes
|
||||||
|
|
||||||
# set to 1 to enable GUI apps
|
# set to 1 to enable GUI apps and/or BIN execution
|
||||||
GUI="${GUI:-0}"
|
GUI="${GUI:-0}"
|
||||||
|
BIN="${BIN:-0}"
|
||||||
|
|
||||||
set -euf -o noclobber -o noglob -o nounset
|
set -euf -o noclobber -o noglob -o nounset
|
||||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}" # protect trailing \n
|
||||||
|
@ -513,10 +515,25 @@ handle_blocked() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_bin() {
|
||||||
|
case "${MIMETYPE}" in
|
||||||
|
application/x-executable|application/x-shellscript)
|
||||||
|
clear
|
||||||
|
echo '-------- Executable File --------' && file --dereference --brief -- "${FPATH}"
|
||||||
|
printf "Run executable (y/N)? "
|
||||||
|
read -r answer
|
||||||
|
case "$answer" in
|
||||||
|
[Yy]* ) exec "${FPATH}";;
|
||||||
|
[Nn]* ) exit;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
MIMETYPE="$( file -bL --mime-type -- "${FPATH}" )"
|
MIMETYPE="$( file -bL --mime-type -- "${FPATH}" )"
|
||||||
handle_extension
|
handle_extension
|
||||||
handle_multimedia "${MIMETYPE}"
|
handle_multimedia "${MIMETYPE}"
|
||||||
handle_mime "${MIMETYPE}"
|
handle_mime "${MIMETYPE}"
|
||||||
|
[ "$BIN" -ne 0 ] && [ -x "${FPATH}" ] && handle_bin
|
||||||
handle_blocked "${MIMETYPE}"
|
handle_blocked "${MIMETYPE}"
|
||||||
handle_fallback
|
handle_fallback
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue