2017-02-19 16:08:06 +03:00
|
|
|
hook global BufOpenFile .* %{ %sh{
|
2016-12-06 16:40:14 +03:00
|
|
|
if [ -z "${kak_opt_filetype}" ]; then
|
|
|
|
mime=$(file -b --mime-type "${kak_buffile}")
|
2016-12-07 16:00:06 +03:00
|
|
|
case "${mime}" in
|
2016-12-14 16:40:00 +03:00
|
|
|
application/*+xml) filetype="xml" ;;
|
|
|
|
message/rfc822) filetype="mail" ;;
|
|
|
|
text/x-shellscript) filetype="sh" ;;
|
2016-12-07 16:00:06 +03:00
|
|
|
text/x-*) filetype="${mime#text/x-}" ;;
|
|
|
|
text/*) filetype="${mime#text/}" ;;
|
|
|
|
esac
|
|
|
|
if [ -n "${filetype}" ]; then
|
|
|
|
printf "set buffer filetype '%s'\n" "${filetype}"
|
2016-12-06 16:40:14 +03:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} }
|