|
12 | 12 | from contextlib import contextmanager, suppress |
13 | 13 | from functools import lru_cache |
14 | 14 | from time import monotonic |
15 | | -from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping, Match, NamedTuple, Optional, Pattern, Tuple, Union, cast |
| 15 | +from typing import ( |
| 16 | + TYPE_CHECKING, |
| 17 | + Any, |
| 18 | + Callable, |
| 19 | + Dict, |
| 20 | + Generator, |
| 21 | + Iterable, |
| 22 | + Iterator, |
| 23 | + List, |
| 24 | + Mapping, |
| 25 | + Match, |
| 26 | + NamedTuple, |
| 27 | + Optional, |
| 28 | + Pattern, |
| 29 | + Sequence, |
| 30 | + Tuple, |
| 31 | + Union, |
| 32 | + cast, |
| 33 | +) |
16 | 34 |
|
17 | 35 | from .constants import ( |
18 | 36 | appname, |
19 | 37 | clear_handled_signals, |
20 | 38 | config_dir, |
21 | 39 | is_macos, |
22 | 40 | is_wayland, |
| 41 | + kitten_exe, |
23 | 42 | runtime_dir, |
24 | 43 | shell_path, |
25 | 44 | ssh_control_master_template, |
26 | 45 | ) |
27 | | -from .fast_data_types import WINDOW_FULLSCREEN, WINDOW_MAXIMIZED, WINDOW_MINIMIZED, WINDOW_NORMAL, Color, open_tty |
| 46 | +from .fast_data_types import WINDOW_FULLSCREEN, WINDOW_MAXIMIZED, WINDOW_MINIMIZED, WINDOW_NORMAL, Color, get_options, open_tty |
28 | 47 | from .rgb import to_color |
29 | 48 | from .types import run_once |
30 | 49 | from .typing import AddressFamily, PopenType, Socket, StartupCtx |
@@ -658,7 +677,6 @@ def get_editor_from_env_vars(opts: Optional[Options] = None) -> List[str]: |
658 | 677 |
|
659 | 678 | def get_editor(opts: Optional[Options] = None, path_to_edit: str = '', line_number: int = 0) -> List[str]: |
660 | 679 | if opts is None: |
661 | | - from .fast_data_types import get_options |
662 | 680 | try: |
663 | 681 | opts = get_options() |
664 | 682 | except RuntimeError: |
@@ -730,7 +748,6 @@ def resolve_abs_or_config_path(path: str, env: Optional[Mapping[str, str]] = Non |
730 | 748 |
|
731 | 749 |
|
732 | 750 | def resolve_custom_file(path: str) -> str: |
733 | | - from .fast_data_types import get_options |
734 | 751 | opts: Optional[Options] = None |
735 | 752 | with suppress(RuntimeError): |
736 | 753 | opts = get_options() |
@@ -786,7 +803,6 @@ def which(name: str, only_system: bool = False) -> Optional[str]: |
786 | 803 | return name |
787 | 804 | import shutil |
788 | 805 |
|
789 | | - from .fast_data_types import get_options |
790 | 806 | opts: Optional[Options] = None |
791 | 807 | with suppress(RuntimeError): |
792 | 808 | opts = get_options() |
@@ -1154,3 +1170,16 @@ def is_png(path: str) -> bool: |
1154 | 1170 | header = f.read(8) |
1155 | 1171 | return header.startswith(b'\211PNG\r\n\032\n') |
1156 | 1172 | return False |
| 1173 | + |
| 1174 | + |
| 1175 | +def cmdline_for_hold(cmd: Sequence[str] = (), opts: Optional['Options'] = None) -> List[str]: |
| 1176 | + if opts is None: |
| 1177 | + with suppress(RuntimeError): |
| 1178 | + opts = get_options() |
| 1179 | + if opts is None: |
| 1180 | + from .options.types import defaults |
| 1181 | + opts = defaults |
| 1182 | + ksi = ' '.join(opts.shell_integration) |
| 1183 | + import shlex |
| 1184 | + shell = shlex.join(resolved_shell(opts)) |
| 1185 | + return [kitten_exe(), 'run-shell', f'--shell={shell}', f'--shell-integration={ksi}'] + list(cmd) |
0 commit comments