瀏覽代碼

Keep preview-tui generic

master
Arun Prakash Jana 4 年之前
父節點
當前提交
5dbb511ede
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: A75979F35C080412
共有 1 個檔案被更改,包括 14 行新增6 行删除
  1. +14
    -6
      plugins/preview-tui

+ 14
- 6
plugins/preview-tui 查看文件

@@ -40,8 +40,11 @@ preview_file () {
clear

encoding="$(file -b --mime-encoding "$1")"

# Detect mime type
mimetype="$(file --dereference --brief --mime-type -- "$1")"

# Detect file extention
ext="${1##*.}"
if ! [ -z "$ext" ]; then
ext="$(printf "%s" "${ext}" | tr '[:upper:]' '[:lower:]')"
@@ -52,7 +55,7 @@ preview_file () {

cd "$1" || return

# we use a FIFO to access less PID
# We use a FIFO to access less PID
tmpfifopath="${TMPDIR:-/tmp}/nnn-preview-tui-fifo.$$"
mkfifo "$tmpfifopath" || return

@@ -64,15 +67,20 @@ preview_file () {
)

rm "$tmpfifopath"
elif beginswith "$mimetype" "image/" ; then
viu "$1" | head -n "$lines"
elif beginswith "$mimetype" "text/troff" ; then
man -l "$1" &
#elif beginswith "$mimetype" "image/" ; then
# viu "$1" | head -n "$lines"
#elif beginswith "$mimetype" "text/troff" ; then
# man -l "$1" &
elif beginswith "$mimetype" "application/zip" ; then
#$PAGER "$(zip -sf "$1")" &
$PAGER "$(unzip -l "$1")" &
elif [ "$ext" = "gz" ] || [ "$ext" = "bz2" ] ; then
$PAGER "$(tar -tvf "$1")" &
elif [ "$encoding" = "binary" ] ; then
# Binary file: just print filetype info
echo "-------- binary file --------"
file -b "$1"
echo "-------- stat --------"
echo ''
stat "$1"
else
# Text file:


Loading…
取消
儲存