mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-14 20:44:32 +02:00
Also detect makefiles as plain text files
This commit is contained in:
@@ -41,9 +41,14 @@ text_mimes = (
|
||||
)
|
||||
|
||||
|
||||
def is_rc_file(path: str) -> bool:
|
||||
def is_special_file(path: str) -> Optional[str]:
|
||||
name = os.path.basename(path)
|
||||
return '.' not in name and name.endswith('rc')
|
||||
lname = name.lower()
|
||||
if lname == 'makefile' or lname.startswith('makefile.'):
|
||||
return 'text/makefile'
|
||||
if '.' not in name and name.endswith('rc'):
|
||||
return 'text/plain' # rc file
|
||||
return None
|
||||
|
||||
|
||||
def is_folder(path: str) -> bool:
|
||||
@@ -90,8 +95,7 @@ def guess_type(path: str, allow_filesystem_access: bool = False) -> Optional[str
|
||||
mt = known_extensions.get(ext)
|
||||
if mt in text_mimes:
|
||||
mt = f'text/{mt.split("/", 1)[-1]}'
|
||||
if not mt and is_rc_file(path):
|
||||
mt = 'text/plain'
|
||||
mt = mt or is_special_file(path)
|
||||
if not mt:
|
||||
if is_dir:
|
||||
mt = 'inode/directory' # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user