lf: prevent double preview of yaml/json
This commit is contained in:
parent
2ee59d5af1
commit
1e0a3eea4c
1 changed files with 16 additions and 22 deletions
|
@ -23,25 +23,19 @@ video() {
|
|||
}
|
||||
|
||||
text() {
|
||||
for cmd in bat batcat head; do
|
||||
for cmd in bat batcat; 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 \
|
||||
--line-range=":$h" \
|
||||
--terminal-width="$((w - 2))" "$@" "$f"
|
||||
;;
|
||||
head)
|
||||
head -n "$h" "$f"
|
||||
;;
|
||||
esac
|
||||
$cmd \
|
||||
--color=always \
|
||||
--italic-text=always \
|
||||
--style=plain \
|
||||
--pager=never \
|
||||
--tabs=4 \
|
||||
--theme=base16 \
|
||||
--line-range=":$h" \
|
||||
--terminal-width="$((w - 2))" \
|
||||
"$@"
|
||||
}
|
||||
|
||||
run() {
|
||||
|
@ -67,8 +61,8 @@ mimetest() {
|
|||
*/vnd.sun.xml.writer) run odt2txt "$f" ;;
|
||||
*/msword) run catdoc "$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.openxmlformats-officedocument.spreadsheetml.sheet) 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 "$f" ;;
|
||||
*/pgp-encrypted) run gpg -d -- "$f" ;;
|
||||
*/pkix-cert) run openssl x509 -text -noout -in "$f" ;;
|
||||
*opendocument*) run odt2txt "$f" ;;
|
||||
|
@ -84,9 +78,9 @@ mimetest() {
|
|||
*/*yaml)
|
||||
# [ ! -f "${CACHE}.txt" ] && run yq -C <"$f" >"${CACHE}.txt"
|
||||
# text "${CACHE}.txt"
|
||||
text --language=yaml
|
||||
text --language=yaml "$f"
|
||||
;;
|
||||
*/*lua) text ;;
|
||||
*/*lua) text "$f" ;;
|
||||
*/epub+zip)
|
||||
[ ! -f "$CACHE" ] && run epub-thumbnailer "$f" "$CACHE" 1024
|
||||
image "$CACHE"
|
||||
|
@ -101,7 +95,7 @@ mimetest() {
|
|||
;;
|
||||
video/*) video ;;
|
||||
image/*) image ;;
|
||||
*text*) text ;;
|
||||
*text*) text "$f" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue