mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 09:48:09 +02:00
Add completion for the kittens
This commit is contained in:
@@ -17,7 +17,7 @@ from typing import (
|
||||
Any, DefaultDict, Dict, Iterable, Iterator, List, Optional, Tuple, Union
|
||||
)
|
||||
|
||||
from kitty.cli import CONFIG_HELP, parse_args
|
||||
from kitty.cli import CONFIG_HELP, parse_args, CompletionSpec
|
||||
from kitty.cli_stub import DiffCLIOptions
|
||||
from kitty.conf.utils import KeyAction
|
||||
from kitty.constants import appname
|
||||
@@ -577,6 +577,7 @@ number set in :file:`diff.conf`.
|
||||
|
||||
--config
|
||||
type=list
|
||||
completion=type:file ext:conf group:"Config files" kwds:none,NONE
|
||||
{config_help}
|
||||
|
||||
|
||||
@@ -687,6 +688,7 @@ elif __name__ == '__doc__':
|
||||
cd['usage'] = usage
|
||||
cd['options'] = OPTIONS
|
||||
cd['help_text'] = help_text
|
||||
cd['args_completion'] = CompletionSpec.from_string('type:file mime:text/* mime:image/* group:"Text and image files"')
|
||||
elif __name__ == '__conf__':
|
||||
from .options.definition import definition
|
||||
sys.options_definition = definition # type: ignore
|
||||
|
||||
@@ -15,7 +15,7 @@ from typing import (
|
||||
Dict, Generator, List, NamedTuple, Optional, Pattern, Tuple, Union
|
||||
)
|
||||
|
||||
from kitty.cli import parse_args
|
||||
from kitty.cli import parse_args, CompletionSpec
|
||||
from kitty.cli_stub import IcatCLIOptions
|
||||
from kitty.constants import appname
|
||||
from kitty.guess_mime_type import guess_type
|
||||
@@ -622,3 +622,4 @@ elif __name__ == '__doc__':
|
||||
cd['usage'] = usage
|
||||
cd['options'] = options_spec
|
||||
cd['help_text'] = help_text
|
||||
cd['args_completion'] = CompletionSpec.from_string('type:file mime:image/* group:Images')
|
||||
|
||||
@@ -8,17 +8,20 @@ import os
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import sys
|
||||
import tempfile
|
||||
import zipfile
|
||||
from contextlib import suppress
|
||||
from typing import Any, Callable, Dict, Iterator, Match, Optional, Tuple, Union, Type
|
||||
from typing import (
|
||||
Any, Callable, Dict, Iterator, Match, Optional, Tuple, Type, Union
|
||||
)
|
||||
from urllib.error import HTTPError
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
from kitty.config import atomic_save, parse_config
|
||||
from kitty.constants import cache_dir, config_dir
|
||||
from kitty.options.types import Options as KittyOptions
|
||||
from kitty.fast_data_types import Color
|
||||
from kitty.options.types import Options as KittyOptions
|
||||
from kitty.utils import reload_conf_in_all_kitties
|
||||
|
||||
from ..choose.match import match
|
||||
@@ -647,3 +650,13 @@ def load_themes(cache_age: float = 1., ignore_no_cache: bool = False) -> Themes:
|
||||
ans.load_from_dir(os.path.join(config_dir, 'themes'))
|
||||
ans.index_map = tuple(ans.themes)
|
||||
return ans
|
||||
|
||||
|
||||
def print_theme_names() -> None:
|
||||
found = False
|
||||
for theme in load_themes(cache_age=-1, ignore_no_cache=True):
|
||||
print(theme.name)
|
||||
found = True
|
||||
if not found:
|
||||
print('Default')
|
||||
sys.stdout.flush()
|
||||
|
||||
@@ -11,12 +11,12 @@ from typing import (
|
||||
Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, Union
|
||||
)
|
||||
|
||||
from kitty.cli import create_default_opts, parse_args
|
||||
from kitty.cli import CompletionSpec, create_default_opts, parse_args
|
||||
from kitty.cli_stub import ThemesCLIOptions
|
||||
from kitty.config import cached_values_for
|
||||
from kitty.options.types import Options as KittyOptions
|
||||
from kitty.constants import config_dir
|
||||
from kitty.fast_data_types import truncate_point_for_length, wcswidth
|
||||
from kitty.options.types import Options as KittyOptions
|
||||
from kitty.rgb import color_as_sharp, color_from_int
|
||||
from kitty.typing import KeyEventType
|
||||
from kitty.utils import ScreenSize
|
||||
@@ -616,3 +616,4 @@ elif __name__ == '__doc__':
|
||||
cd['usage'] = usage
|
||||
cd['options'] = OPTIONS
|
||||
cd['help_text'] = help_text
|
||||
cd['args_completion'] = CompletionSpec.from_string('type:special group:complete_themes')
|
||||
|
||||
Reference in New Issue
Block a user