lf: optimize previews
This commit is contained in:
parent
26a8e9e4ce
commit
6b1d52807f
|
@ -11,7 +11,7 @@ image() {
|
|||
file=${1:-$f}
|
||||
# shellcheck disable=2086
|
||||
chafa -f sixel -s "${w}x${h}" --polite on --animate false "$file"
|
||||
exit 0
|
||||
exit
|
||||
}
|
||||
|
||||
video() {
|
||||
|
@ -23,15 +23,24 @@ video() {
|
|||
}
|
||||
|
||||
text() {
|
||||
bat \
|
||||
--color=always \
|
||||
--italic-text=always \
|
||||
--style=plain \
|
||||
--pager=never \
|
||||
--tabs=4 \
|
||||
--theme=base16 \
|
||||
--terminal-width="$((w - 2))" "$@" "$f"
|
||||
exit 1
|
||||
for cmd in bat batcat cat; do
|
||||
command -v $cmd >/dev/null 2>&1 && break
|
||||
done
|
||||
case $cmd in
|
||||
bat*)
|
||||
$cmd \
|
||||
--color=always \
|
||||
--italic-text=always \
|
||||
--style=plain \
|
||||
--pager=never \
|
||||
--tabs=4 \
|
||||
--theme=base16 \
|
||||
--terminal-width="$((w - 2))" "$@" "$f"
|
||||
;;
|
||||
cat)
|
||||
$cmd "$f"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
run() {
|
||||
|
@ -101,13 +110,13 @@ CACHE="${XDG_CACHE_HOME}/lf/$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$(readl
|
|||
# Special cases
|
||||
[ "$(dirname "$(realpath "$f")" | rev | cut -d/ -f1 | rev)" = "factscache" ] &&
|
||||
[ -f "$(dirname "$(dirname "$(realpath "$f")")")/ansible.cfg" ] &&
|
||||
jq -C <"$f" && exit 1
|
||||
jq -C <"$f" && exit
|
||||
|
||||
giorun="$(gio info "$f" 2>/dev/null | grep standard::content-type | cut -d' ' -f4)"
|
||||
mimetest "$giorun" && exit 1
|
||||
mimetest "$giorun" && exit
|
||||
|
||||
filerun="$(file --brief --dereference --mime-type "$f")"
|
||||
mimetest "$filerun" && exit 1
|
||||
mimetest "$filerun" && exit
|
||||
|
||||
printf "%b" "\$(file --mime-type)\t\t\t : $filerun\n"
|
||||
[ -n "$giorun" ] && printf "%b" "\$(gio info)\t\t\t\t : $giorun\n"
|
||||
|
|
Loading…
Reference in New Issue