2017-02-19 14:08:06 +01:00
|
|
|
hook global BufOpenFile .* %{ %sh{
|
2016-12-06 14:40:14 +01:00
|
|
|
if [ -z "${kak_opt_filetype}" ]; then
|
|
|
|
mime=$(file -b --mime-type "${kak_buffile}")
|
2016-12-07 14:00:06 +01:00
|
|
|
case "${mime}" in
|
2016-12-14 14:40:00 +01:00
|
|
|
application/*+xml) filetype="xml" ;;
|
|
|
|
message/rfc822) filetype="mail" ;;
|
|
|
|
text/x-shellscript) filetype="sh" ;;
|
2016-12-07 14:00:06 +01: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 14:40:14 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
} }
|