lf: force .heex files to preview as text/plain
This commit is contained in:
parent
a98448fad0
commit
9406c5581a
1 changed files with 10 additions and 3 deletions
|
@ -180,21 +180,28 @@ preview() {
|
|||
esac
|
||||
}
|
||||
|
||||
extension_override() {
|
||||
case "${f##*.}" in
|
||||
heex) printf "%s" "text/plain" ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# We don't want to reprocess files in the cache, as this will generate a bunch of duplicate cache entries
|
||||
[ "$(readlink -f "$f" | xargs dirname)" = "${CACHE_DIR}" ] && {
|
||||
stat -c "%w" "$f"
|
||||
exit
|
||||
}
|
||||
|
||||
# First mimetype detection is made with 'gio info'
|
||||
mimetype_override="$(extension_override "$f")"
|
||||
preview "$mimetype_override" && exit
|
||||
|
||||
mimetype_gio="$(gio info "$f" 2>/dev/null | grep standard::content-type | cut -d' ' -f4)"
|
||||
preview "$mimetype_gio" && exit
|
||||
|
||||
# If gio detection fails, we try again with 'file --mime-type'
|
||||
mimetype_file="$(file --brief --dereference --mime-type "$f")"
|
||||
preview "$mimetype_file" && exit
|
||||
|
||||
# If all detection fails, simply print the results of file and gio
|
||||
[ -n "$mimetype_gio" ] && printf '$(gio info)\t\t\t\t : %s\n' "${mimetype_gio}"
|
||||
[ -n "$mimetype_file" ] && printf '$(file --mime-type)\t\t\t : %s\n' "${mimetype_file}"
|
||||
mediainfo "$1" | head -n -2 | grep -v -e "Complete name" -e "General"
|
||||
|
|
Loading…
Add table
Reference in a new issue