mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
preview-tui: make scope & pistol run before file
(#647)
Both Pistol and `scope.sh` are run `file --mimetype` or an equivalent, internally. Thus, for speed, it's better to run them before almost anything else.
This commit is contained in:
parent
7b68844a05
commit
92ff1447c0
|
@ -114,17 +114,6 @@ preview_file () {
|
||||||
kill %- %+ 2>/dev/null && wait %- %+ 2>/dev/null
|
kill %- %+ 2>/dev/null && wait %- %+ 2>/dev/null
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Detecting the exact type of the file: the encoding, mime type, and
|
|
||||||
# extension in lowercase.
|
|
||||||
encoding="$(file -Lb --mime-encoding -- "$1")"
|
|
||||||
mimetype="$(file -Lb --mime-type -- "$1")"
|
|
||||||
ext="${1##*.}"
|
|
||||||
if [ -n "$ext" ]; then
|
|
||||||
ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')"
|
|
||||||
fi
|
|
||||||
lines=$(($(tput lines)-1))
|
|
||||||
cols=$(tput cols)
|
|
||||||
|
|
||||||
# Trying to use pistol if it's available.
|
# Trying to use pistol if it's available.
|
||||||
if [ "$USE_PISTOL" -ne 0 ] && exists pistol; then
|
if [ "$USE_PISTOL" -ne 0 ] && exists pistol; then
|
||||||
fifo_pager pistol "$1"
|
fifo_pager pistol "$1"
|
||||||
|
@ -138,6 +127,17 @@ preview_file () {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Detecting the exact type of the file: the encoding, mime type, and
|
||||||
|
# extension in lowercase.
|
||||||
|
encoding="$(file -Lb --mime-encoding -- "$1")"
|
||||||
|
mimetype="$(file -Lb --mime-type -- "$1")"
|
||||||
|
ext="${1##*.}"
|
||||||
|
if [ -n "$ext" ]; then
|
||||||
|
ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
fi
|
||||||
|
lines=$(($(tput lines)-1))
|
||||||
|
cols=$(tput cols)
|
||||||
|
|
||||||
# Otherwise, falling back to the defaults.
|
# Otherwise, falling back to the defaults.
|
||||||
if [ -d "$1" ]; then
|
if [ -d "$1" ]; then
|
||||||
cd "$1" || return
|
cd "$1" || return
|
||||||
|
|
Loading…
Reference in a new issue