Store the shell_integration option as a set
This commit is contained in:
parent
9441cf15c3
commit
c8c6f8691f
@ -231,7 +231,7 @@ class Child:
|
||||
env['TERMINFO'] = tdir
|
||||
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
|
||||
opts = fast_data_types.get_options()
|
||||
if opts.shell_integration != 'disabled':
|
||||
if 'disabled' not in opts.shell_integration:
|
||||
from .shell_integration import modify_shell_environ
|
||||
modify_shell_environ(self.argv[0], opts, env)
|
||||
env = {k: v for k, v in env.items() if v is not DELETE_ENV_VAR}
|
||||
|
||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@ -547,7 +547,7 @@ class Options:
|
||||
selection_background: typing.Optional[kitty.fast_data_types.Color] = Color(255, 250, 205)
|
||||
selection_foreground: typing.Optional[kitty.fast_data_types.Color] = Color(0, 0, 0)
|
||||
shell: str = '.'
|
||||
shell_integration: str = 'enabled'
|
||||
shell_integration: typing.FrozenSet[str] = frozenset({'enabled'})
|
||||
single_window_margin_width: FloatEdges = FloatEdges(left=-1.0, top=-1.0, right=-1.0, bottom=-1.0)
|
||||
startup_session: typing.Optional[str] = None
|
||||
strip_trailing_spaces: choices_for_strip_trailing_spaces = 'never'
|
||||
|
||||
@ -6,8 +6,8 @@ import os
|
||||
import re
|
||||
import sys
|
||||
from typing import (
|
||||
Any, Callable, Container, Dict, Iterable, Iterator, List, NamedTuple,
|
||||
Optional, Sequence, Tuple, Union
|
||||
Any, Callable, Container, Dict, FrozenSet, Iterable, Iterator, List,
|
||||
NamedTuple, Optional, Sequence, Tuple, Union
|
||||
)
|
||||
|
||||
import kitty.fast_data_types as defines
|
||||
@ -766,13 +766,13 @@ def watcher(val: str, current_val: Container[str]) -> Iterable[Tuple[str, str]]:
|
||||
yield val, val
|
||||
|
||||
|
||||
def shell_integration(x: str) -> str:
|
||||
s = {'enabled', 'disabled', 'no-rc', 'no-cursor', 'no-title', 'no-prompt-mark', 'no-complete'}
|
||||
q = set(x.split())
|
||||
def shell_integration(x: str) -> FrozenSet[str]:
|
||||
s = frozenset({'enabled', 'disabled', 'no-rc', 'no-cursor', 'no-title', 'no-prompt-mark', 'no-complete'})
|
||||
q = frozenset(x.lower().split())
|
||||
if not q.issubset(s):
|
||||
log_error(f'Invalid shell integration options: {q - s}, ignoring')
|
||||
return ' '.join(q & s)
|
||||
return x
|
||||
return q & s
|
||||
return q
|
||||
|
||||
|
||||
def action_alias(val: str) -> Iterable[Tuple[str, str]]:
|
||||
|
||||
@ -108,10 +108,7 @@ def get_supported_shell_name(path: str) -> Optional[str]:
|
||||
|
||||
|
||||
def shell_integration_allows_rc_modification(opts: Options) -> bool:
|
||||
q = set(opts.shell_integration.split())
|
||||
if q & {'disabled', 'no-rc'}:
|
||||
return False
|
||||
return True
|
||||
return not bool(opts.shell_integration & {'disabled', 'no-rc'})
|
||||
|
||||
|
||||
def setup_shell_integration(opts: Options, env: Dict[str, str]) -> bool:
|
||||
@ -133,9 +130,9 @@ def setup_shell_integration(opts: Options, env: Dict[str, str]) -> bool:
|
||||
|
||||
def modify_shell_environ(argv0: str, opts: Options, env: Dict[str, str]) -> None:
|
||||
shell = get_supported_shell_name(argv0)
|
||||
if shell is None or 'disabled' in set(opts.shell_integration.split()):
|
||||
if shell is None or 'disabled' in opts.shell_integration:
|
||||
return
|
||||
env['KITTY_SHELL_INTEGRATION'] = opts.shell_integration
|
||||
env['KITTY_SHELL_INTEGRATION'] = ' '.join(opts.shell_integration)
|
||||
if not shell_integration_allows_rc_modification(opts):
|
||||
return
|
||||
f = ENV_MODIFIERS.get(shell)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user