lf: prevent double preview of yaml/json
This commit is contained in:
parent
f69b9957c9
commit
50469288e9
|
@ -23,25 +23,19 @@ video() {
|
||||||
}
|
}
|
||||||
|
|
||||||
text() {
|
text() {
|
||||||
for cmd in bat batcat head; do
|
for cmd in bat batcat; do
|
||||||
command -v $cmd >/dev/null 2>&1 && break
|
command -v $cmd >/dev/null 2>&1 && break
|
||||||
done
|
done
|
||||||
case $cmd in
|
$cmd \
|
||||||
bat*)
|
--color=always \
|
||||||
$cmd \
|
--italic-text=always \
|
||||||
--color=always \
|
--style=plain \
|
||||||
--italic-text=always \
|
--pager=never \
|
||||||
--style=plain \
|
--tabs=4 \
|
||||||
--pager=never \
|
--theme=base16 \
|
||||||
--tabs=4 \
|
--line-range=":$h" \
|
||||||
--theme=base16 \
|
--terminal-width="$((w - 2))" \
|
||||||
--line-range=":$h" \
|
"$@"
|
||||||
--terminal-width="$((w - 2))" "$@" "$f"
|
|
||||||
;;
|
|
||||||
head)
|
|
||||||
head -n "$h" "$f"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
|
@ -67,8 +61,8 @@ mimetest() {
|
||||||
*/vnd.sun.xml.writer) run odt2txt "$f" ;;
|
*/vnd.sun.xml.writer) run odt2txt "$f" ;;
|
||||||
*/msword) run catdoc "$f" ;;
|
*/msword) run catdoc "$f" ;;
|
||||||
*/vnd.openxmlformats-officedocument.wordprocessingml.document) run docx2txt <"$f" ;;
|
*/vnd.openxmlformats-officedocument.wordprocessingml.document) run docx2txt <"$f" ;;
|
||||||
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
|
*/vnd.ms-excel) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv "$f" ;;
|
||||||
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv ;;
|
*/vnd.openxmlformats-officedocument.spreadsheetml.sheet) run ssconvert --export-type=Gnumeric_stf:stf_csv "$f" "fd://1" | text --language=csv "$f" ;;
|
||||||
*/pgp-encrypted) run gpg -d -- "$f" ;;
|
*/pgp-encrypted) run gpg -d -- "$f" ;;
|
||||||
*/pkix-cert) run openssl x509 -text -noout -in "$f" ;;
|
*/pkix-cert) run openssl x509 -text -noout -in "$f" ;;
|
||||||
*opendocument*) run odt2txt "$f" ;;
|
*opendocument*) run odt2txt "$f" ;;
|
||||||
|
@ -84,9 +78,9 @@ mimetest() {
|
||||||
*/*yaml)
|
*/*yaml)
|
||||||
# [ ! -f "${CACHE}.txt" ] && run yq -C <"$f" >"${CACHE}.txt"
|
# [ ! -f "${CACHE}.txt" ] && run yq -C <"$f" >"${CACHE}.txt"
|
||||||
# text "${CACHE}.txt"
|
# text "${CACHE}.txt"
|
||||||
text --language=yaml
|
text --language=yaml "$f"
|
||||||
;;
|
;;
|
||||||
*/*lua) text ;;
|
*/*lua) text "$f" ;;
|
||||||
*/epub+zip)
|
*/epub+zip)
|
||||||
[ ! -f "$CACHE" ] && run epub-thumbnailer "$f" "$CACHE" 1024
|
[ ! -f "$CACHE" ] && run epub-thumbnailer "$f" "$CACHE" 1024
|
||||||
image "$CACHE"
|
image "$CACHE"
|
||||||
|
@ -101,7 +95,7 @@ mimetest() {
|
||||||
;;
|
;;
|
||||||
video/*) video ;;
|
video/*) video ;;
|
||||||
image/*) image ;;
|
image/*) image ;;
|
||||||
*text*) text ;;
|
*text*) text "$f" ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue