FPATH="$1"
FNAME=$(basename "$1")
+EDITOR="${EDITOR:-vi}"
+PAGER="${PAGER:-less -R}"
ext="${FNAME##*.}"
if ! [ -z "$ext" ]; then
ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')"
exit 0
elif which pdftotext >/dev/null 2>&1; then
## Preview as text conversion
- pdftotext -l 10 -nopgbrk -q -- "${FPATH}" - | less -R
+ pdftotext -l 10 -nopgbrk -q -- "${FPATH}" - | eval "$PAGER"
exit 0
elif which mutool >/dev/null 2>&1; then
mutool draw -F txt -i -- "${FPATH}" 1-10
exit 0
elif which exiftool >/dev/null 2>&1; then
- exiftool "${FPATH}" | less -R
+ exiftool "${FPATH}" | eval "$PAGER"
exit 0
fi
}
mpv "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which mediainfo >/dev/null 2>&1; then
- mediainfo "${FPATH}" | less -R
+ mediainfo "${FPATH}" | eval "$PAGER"
exit 0
elif which exiftool >/dev/null 2>&1; then
- exiftool "${FPATH}"| less -R
+ exiftool "${FPATH}"| eval "$PAGER"
exit 0
fi
}
# Thumbnail
[ -d "${IMAGE_CACHE_PATH}" ] || mkdir "${IMAGE_CACHE_PATH}"
ffmpegthumbnailer -i "${FPATH}" -o "${IMAGE_CACHE_PATH}/${FNAME}.jpg" -s 0
- viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | less -R
+ viu -n "${IMAGE_CACHE_PATH}/${FNAME}.jpg" | eval "$PAGER"
exit 0
elif which mediainfo >/dev/null 2>&1; then
- mediainfo "${FPATH}" | less -R
+ mediainfo "${FPATH}" | eval "$PAGER"
exit 0
elif which exiftool >/dev/null 2>&1; then
- exiftool "${FPATH}"| less -R
+ exiftool "${FPATH}"| eval "$PAGER"
exit 0
fi
}
a|ace|alz|arc|arj|bz|bz2|cab|cpio|deb|gz|jar|lha|lz|lzh|lzma|lzo|\
rpm|rz|t7z|tar|tbz|tbz2|tgz|tlz|txz|tZ|tzo|war|xpi|xz|Z|zip)
if which atool >/dev/null 2>&1; then
- atool --list -- "${FPATH}" | less -R
+ atool --list -- "${FPATH}" | eval "$PAGER"
exit 0
elif which bsdtar >/dev/null 2>&1; then
- bsdtar --list --file "${FPATH}" | less -R
+ bsdtar --list --file "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
rar)
if which unrar >/dev/null 2>&1; then
## Avoid password prompt by providing empty password
- unrar lt -p- -- "${FPATH}" | less -R
+ unrar lt -p- -- "${FPATH}" | eval "$PAGER"
fi
exit 1;;
7z)
if which 7z >/dev/null 2>&1; then
## Avoid password prompt by providing empty password
- 7z l -p -- "${FPATH}" | less -R
+ 7z l -p -- "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
## Log files
log)
- vi "${FPATH}"
+ "$EDITOR" "${FPATH}"
exit 0;;
## BitTorrent
odt|ods|odp|sxw)
if which odt2txt >/dev/null 2>&1; then
## Preview as text conversion
- odt2txt "${FPATH}" | less -R
+ odt2txt "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;
## Markdown
md)
if which glow >/dev/null 2>&1; then
- glow -sdark "${FPATH}" | less -R
+ glow -sdark "${FPATH}" | eval "$PAGER"
exit 0
elif which lowdown >/dev/null 2>&1; then
- lowdown -Tterm "${FPATH}" | less -R
+ lowdown -Tterm "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
htm|html|xhtml)
## Preview as text conversion
if which w3m >/dev/null 2>&1; then
- w3m -dump "${FPATH}" | less -R
+ w3m -dump "${FPATH}" | eval "$PAGER"
exit 0
elif which lynx >/dev/null 2>&1; then
- lynx -dump -- "${FPATH}" | less -R
+ lynx -dump -- "${FPATH}" | eval "$PAGER"
exit 0
elif which elinks >/dev/null 2>&1; then
- elinks -dump "${FPATH}" | less -R
+ elinks -dump "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
## JSON
json)
if which jq >/dev/null 2>&1; then
- jq --color-output . "${FPATH}" | less -R
+ jq --color-output . "${FPATH}" | eval "$PAGER"
exit 0
elif which python >/dev/null 2>&1; then
- python -m json.tool -- "${FPATH}" | less -R
+ python -m json.tool -- "${FPATH}" | eval "$PAGER"
exit 0
fi
;;
sxiv_load_dir "${FPATH}" >/dev/null 2>&1 &
exit 0
elif which viu >/dev/null 2>&1; then
- viu -n "${FPATH}" | less -R
+ viu -n "${FPATH}" | eval "$PAGER"
exit 0
elif which img2txt >/dev/null 2>&1; then
- img2txt --gamma=0.6 -- "${FPATH}" | less -R
+ img2txt --gamma=0.6 -- "${FPATH}" | eval "$PAGER"
exit 0
elif which exiftool >/dev/null 2>&1; then
- exiftool "${FPATH}" | less -R
+ exiftool "${FPATH}" | eval "$PAGER"
exit 0
fi
# local orientation
## Text
text/* | */xml)
- vi "${FPATH}"
+ "$EDITOR" "${FPATH}"
exit 0;;
## Syntax highlight
# if [[ "$( stat --printf='%s' -- "${FPATH}" )" -gt "${HIGHLIGHT_SIZE_MAX}" ]]; then
image/vnd.djvu)
if which djvutxt >/dev/null 2>&1; then
## Preview as text conversion (requires djvulibre)
- djvutxt "${FPATH}" | less -R
+ djvutxt "${FPATH}" | eval "$PAGER"
exit 0
elif which exiftool >/dev/null 2>&1; then
- exiftool "${FPATH}" | less -R
+ exiftool "${FPATH}" | eval "$PAGER"
exit 0
fi
exit 1;;