Commit Graph

10 Commits

Author SHA1 Message Date
throwawayaccount12345-1
3ab88f4b7c
rc file-detection hook group
Add a group to the `file-detection` hooks.

There's no way to remove hooks without a group. With this patch, you'll be able to remove those
`file-detection` hooks manually. There's no need for two separate groups since if you wanted to
remove only one, you could run `remove-hooks` and then only add one again.


Related: #3670
2022-04-20 23:11:10 -03:00
Maxime Coste
40270a9c8b Merge remote-tracking branch 'Eluminae/master' 2021-04-25 20:23:10 +10:00
codesoap
c9f07702f9 file.kak: Acknowledge mime type application/x-shellscript 2020-12-23 22:45:07 +01:00
Reed Wade
36631fc473
Detect filetype on buffer save too
This allow kaking a new file, add a shebang in the first line, and get
the right filetype detected automatically on save.
2020-11-17 22:32:09 +01:00
Johannes Altmanninger
407c72d90a Clear unwanted environment variable
This adds two things I forgot in
9a7d8df4 (Avoid accidentally using environment variables in sh scopes)

Mea culpa, the problem was that I was skipping matches with "filetype"
because that's usually just a hook parameter as in "WinSetOption filetype=.."

	rg --pcre2 '\b(?!filetype=)\w+=' rc/

So I missed these two cases where a shell variable is actually called "filetype".

The one in git.kak was not a problem because show_git_cmd_output is only
ever called with sane inputs.  However, file.kak does use the filetype
environment variable for many mime types, for example:

	filetype=somefiletype\''; echo -debug injection; nop '\' kak /dev/null

Will run the echo since /dev/null has mime type "inode/chardevice"
2020-09-02 06:54:19 +02:00
Jason Felice
bdd7ea6a03 Detect text/x-script.* and application/x-* types 2020-06-12 11:29:55 -04:00
Matthias Margush
99c09daec3 Fix filetype detection
The -i flag on Mac OS means:
    ჻ man file | grep -i -- -i
    -i      If the file is a regular file, do not classify its contents.

The --mime-type option is (mostly) portable:
- Linux uses --mime-type
- macOS uses --mime-type
- FreeBSD uses --mime-type
- NetBSD uses --mime-type
- OpenBSD uses --mime-type and does not use the same implementation as everybody else
- Solaris does not support MIME types at all
2020-02-21 21:25:57 -08:00
Alex Leferry 2
ba1274f73c file.kak: Dereference symlinks 2019-04-17 12:37:54 +02:00
Alex Leferry 2
313c6eadc7 file.kak: Use -i POSIX option name
https://ss64.com/osx/file.html
https://freebsd.org/cgi/man.cgi?query=file
2019-04-17 12:37:17 +02:00
Alex Leferry 2
c0dccdd90d Add categories in rc/
Closes #2783
2019-03-21 01:06:16 +01:00