smarter mimetype matching
This commit is contained in:
parent
74432ac8f2
commit
5fcb99a154
|
@ -3,9 +3,12 @@ decl str mimetype
|
||||||
hook global BufOpen .* %{ %sh{
|
hook global BufOpen .* %{ %sh{
|
||||||
if [ -z "${kak_opt_filetype}" ]; then
|
if [ -z "${kak_opt_filetype}" ]; then
|
||||||
mime=$(file -b --mime-type "${kak_buffile}")
|
mime=$(file -b --mime-type "${kak_buffile}")
|
||||||
printf %s\\n "${mime}" | grep -q '^text/x-'
|
case "${mime}" in
|
||||||
if [ $? -eq 0 ]; then
|
text/x-*) filetype="${mime#text/x-}" ;;
|
||||||
printf "set buffer filetype '%s'\n" "${mime:7}"
|
text/*) filetype="${mime#text/}" ;;
|
||||||
|
esac
|
||||||
|
if [ -n "${filetype}" ]; then
|
||||||
|
printf "set buffer filetype '%s'\n" "${filetype}"
|
||||||
else
|
else
|
||||||
printf "set buffer mimetype '%s'\n" "${mime}"
|
printf "set buffer mimetype '%s'\n" "${mime}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user