"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "plugins/nuke" between
nnn-v4.1.1.tar.gz and nnn-v4.2.tar.gz

About: nnn is a full-featured terminal file manager.

nuke  (nnn-v4.1.1):nuke  (nnn-v4.2)
skipping to change at line 24 skipping to change at line 24
# nnn -c # nnn -c
# # The -c program option overrides option -e # # The -c program option overrides option -e
# 3. nuke can use nnn plugins (e.g. mocq is used for audio), $PATH is updated. # 3. nuke can use nnn plugins (e.g. mocq is used for audio), $PATH is updated.
# #
# Details: # Details:
# Inspired by ranger's scope.sh, modified for usage with nnn. # Inspired by ranger's scope.sh, modified for usage with nnn.
# #
# 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.
# 2. PAGER is "less -R". # 2. PAGER is "less -R".
# 3. Start GUI apps in bg to unblock. Redirect stdout and strerr if required. # 3. Start GUI apps in bg to unblock. Redirect stdout and strerr if required.
# 4. Some CLI utilities are piped to the $PAGER, to wait and quit uniformly. # 4. Some CLI utilities are piped to the $PAGER, to wait and quit uniformly.
# 5. If the output cannot be paged use "read -r _" to wait for user input. # 5. If the output cannot be paged use "read -r _" to wait for user input.
# 6. On a DE, try 'xdg-open' or 'open' in handle_fallback() as last resort. # 6. On a DE, try 'xdg-open' or 'open' in handle_fallback() as last resort.
# #
# Feel free to change the utilities to your favourites and add more mimes. # Feel free to change the utilities to your favourites and add more mimes.
skipping to change at line 66 skipping to change at line 67
# application/pdf: zathura (GUI), pdftotext, mutool, exiftool # application/pdf: zathura (GUI), pdftotext, mutool, exiftool
# Other mimes: # Other mimes:
# text/troff: man -l # text/troff: man -l
# text/* | */xml: vi # text/* | */xml: vi
# image/vnd.djvu): djvutxt, exiftool # image/vnd.djvu): djvutxt, exiftool
# #
# TODO: # TODO:
# 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
PATH=$PATH:"${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins" PATH=$PATH:"${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins"
IMAGE_CACHE_PATH="$(dirname "$1")"/.thumbs IMAGE_CACHE_PATH="$(dirname "$1")"/.thumbs
FPATH="$1" FPATH="$1"
FNAME=$(basename "$1") FNAME=$(basename "$1")
EDITOR="${VISUAL:-${EDITOR:-vi}}" EDITOR="${VISUAL:-${EDITOR:-vi}}"
skipping to change at line 515 skipping to change at line 517
exit 0;; exit 0;;
application/x-shellscript) application/x-shellscript)
exit 0;; exit 0;;
application/octet-stream) application/octet-stream)
exit 0;; exit 0;;
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/'a'rgs)? "
read -r answer
case "$answer" in
[Yy]* ) exec "${FPATH}";;
[Aa]* )
printf "args: "
read -r args
exec "${FPATH}" "$args";;
[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
exit 1 exit 1
 End of changes. 5 change blocks. 
4 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)