1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-26 13:02:01 +03:00
kakoune/rc/detection/file.kak
Alex Leferry 2 c0dccdd90d Add categories in rc/
Closes #2783
2019-03-21 01:06:16 +01:00

18 lines
673 B
Plaintext

hook global BufOpenFile .* %{ evaluate-commands %sh{
if [ -z "${kak_opt_filetype}" ]; then
mime=$(file -b --mime-type "${kak_buffile}")
case "${mime}" in
application/*+xml) filetype="xml" ;;
image/*+xml) filetype="xml" ;; #SVG
message/rfc822) filetype="mail" ;;
text/x-shellscript) filetype="sh" ;;
text/x-*) filetype="${mime#text/x-}" ;;
text/*) filetype="${mime#text/}" ;;
application/*) filetype="${mime#application/}" ;;
esac
if [ -n "${filetype}" ]; then
printf "set-option buffer filetype '%s'\n" "${filetype}"
fi
fi
} }