This commit is contained in:
Kovid Goyal
2025-01-07 11:54:06 +05:30
parent 42e0f98a27
commit d7207edf2b
2 changed files with 6 additions and 6 deletions

View File

@@ -5,8 +5,9 @@ import re
import sys import sys
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from contextlib import suppress from contextlib import suppress
from typing import Dict, Literal, Optional, Type from typing import Dict, Optional, Type, get_args
from kitty.conf.utils import OSNames, os_name
from kitty.constants import appname, str_version from kitty.constants import appname, str_version
from kitty.options.types import Options from kitty.options.types import Options
from kitty.terminfo import names from kitty.terminfo import names
@@ -229,11 +230,10 @@ class ClipboardControl(Query):
@query @query
class OSName(Query): class OSName(Query):
name: str = 'os_name' name: str = 'os_name'
help_text: str = 'The name of the OS the terminal is running on. Kitty supports values: linux, macos, bsd or unknown' help_text: str = f'The name of the OS the terminal is running on. Kitty returns values: {", ".join(sorted(get_args(OSNames)))}'
@staticmethod @staticmethod
def get_result(opts: Options, window_id: int, os_window_id: int) -> Literal['macos', 'bsd', 'linux', 'unknown']: def get_result(opts: Options, window_id: int, os_window_id: int) -> OSNames:
from kitty.conf.utils import os_name
return os_name() return os_name()

View File

@@ -176,10 +176,10 @@ class CurrentlyParsing:
currently_parsing = CurrentlyParsing() currently_parsing = CurrentlyParsing()
OSNames = Literal['macos', 'bsd', 'linux', 'unknown']
@run_once @run_once
def os_name() -> Literal['macos', 'bsd', 'linux', 'unknown']: def os_name() -> OSNames:
if is_macos: if is_macos:
return 'macos' return 'macos'
if 'bsd' in _plat: if 'bsd' in _plat: