Skip to content

Commit 198b69e

Browse files
committed
An option to set TERMINFO to the database directly instead of a path
1 parent ad64472 commit 198b69e

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ rsync algorithm to speed up repeated transfers of large files.
4747
Detailed list of changes
4848
-------------------------------------
4949

50+
0.33.2 [future]
51+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52+
53+
- A new option :opt:`terminfo_type` to allow passing the terminfo database embedded into the :envvar:`TERMINFO` env var directly instead of via a file
54+
5055
0.33.1 [2024-03-21]
5156
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5257

docs/glossary.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ Variables that kitty sets when running child programs
164164

165165
.. envvar:: TERMINFO
166166

167-
Path to a directory containing the kitty terminfo database.
167+
Path to a directory containing the kitty terminfo database. Or the terminfo
168+
database itself encoded in base64. See :opt:`terminfo_type`.
168169

169170
.. envvar:: KITTY_INSTALLATION_DIR
170171

kitty/child.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ def getpid() -> str:
179179
return str(os.getpid())
180180

181181

182+
@run_once
183+
def base64_terminfo_data() -> str:
184+
return (b'b64:' + fast_data_types.base64_encode(fast_data_types.terminfo_data(), True)).decode('ascii')
185+
186+
182187
class ProcessDesc(TypedDict):
183188
cwd: Optional[str]
184189
pid: int
@@ -242,9 +247,12 @@ def get_final_env(self) -> Dict[str, str]:
242247
# can use it to display the current directory name rather
243248
# than the resolved path
244249
env['PWD'] = self.cwd
245-
tdir = checked_terminfo_dir()
246-
if tdir:
247-
env['TERMINFO'] = tdir
250+
if opts.terminfo_type == 'path':
251+
tdir = checked_terminfo_dir()
252+
if tdir:
253+
env['TERMINFO'] = tdir
254+
elif opts.terminfo_type == 'direct':
255+
env['TERMINFO'] = base64_terminfo_data()
248256
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
249257
if opts.forward_stdio:
250258
env['KITTY_STDIO_FORWARDED'] = '3'

kitty/fast_data_types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,3 +1560,4 @@ def find_in_memoryview(buf: Union[bytes, memoryview, bytearray], chr: int) -> in
15601560
def replace_c0_codes_except_nl_space_tab(text: str) -> str:...
15611561
@overload
15621562
def replace_c0_codes_except_nl_space_tab(text: Union[bytes, memoryview, bytearray]) -> bytes:...
1563+
def terminfo_data() -> bytes:...

kitty/options/definition.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,6 +3221,18 @@
32213221
'''
32223222
)
32233223

3224+
opt('terminfo_type', 'path', choices=('path', 'direct', 'none'),
3225+
long_text='''
3226+
The value of the :envvar:`TERMINFO` environment variable to set. This variable is
3227+
used by programs running in the terminal to search for terminfo databases. The default value
3228+
of :code:`path` causes kitty to set it to a filesystem location containing the
3229+
kitty terminfo database. A value of :code:`direct` means put the entire database into
3230+
the env var directly. This can be useful when connecting to containers, for example. But,
3231+
note that not all software supports this. A value of :code:`none` means do not touch the variable.
3232+
'''
3233+
)
3234+
3235+
32243236
opt('forward_stdio', 'no', option_type='to_bool', long_text='''
32253237
Forward STDOUT and STDERR of the kitty process to child processes
32263238
as file descriptors 3 and 4. This is useful for debugging as it

kitty/options/parse.py

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kitty/options/types.py

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)