diff options
author | Doron Behar <doron.behar@gmail.com> | 2020-06-10 10:50:38 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-10 13:20:38 +0530 |
commit | 92ff1447c010b450b3dc4004e9976b972841003d (patch) | |
tree | 358132dee7d97258836093bd2ca248d6a7a3ec9a /plugins | |
parent | 7b68844a05230070f917667cc4387a1770397c02 (diff) | |
download | nnn-92ff1447c010b450b3dc4004e9976b972841003d.tar.gz |
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.
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/preview-tui | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/preview-tui b/plugins/preview-tui index 7b4a7a0..45beac5 100755 --- a/plugins/preview-tui +++ b/plugins/preview-tui @@ -114,17 +114,6 @@ preview_file () { kill %- %+ 2>/dev/null && wait %- %+ 2>/dev/null 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. if [ "$USE_PISTOL" -ne 0 ] && exists pistol; then fifo_pager pistol "$1" @@ -138,6 +127,17 @@ preview_file () { return 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. if [ -d "$1" ]; then cd "$1" || return |