From 37938573ca00eea97927b3e946a5272b0d5f2a3f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Aug 2023 14:18:11 +0530 Subject: [PATCH] When running a shell for ``--hold`` set the env variable ``KITTY_HOLD=1`` to allow users to customize what happens For instance the user could have [ "$KITTY_HOLD" = "1" ] && exec kitten __hold_till_enter__ in their shell rc files to get back the previous Press enter or esc to quit behavior. --- docs/changelog.rst | 2 ++ docs/glossary.rst | 5 +++++ kitty/utils.py | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index cfe9200dd..e8ed65be7 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -68,6 +68,8 @@ Detailed list of changes - Fix a regression that caused changing :opt:`text_fg_override_threshold` or :opt:`text_composition_strategy` via config reload causing incorrect rendering (:iss:`6559`) +- When running a shell for ``--hold`` set the env variable ``KITTY_HOLD=1`` to allow users to customize what happens (:disc:`6587`) + 0.29.2 [2023-07-27] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/glossary.rst b/docs/glossary.rst index 64797ddc2..a4fdde0c6 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -223,3 +223,8 @@ Variables that kitty sets when running child programs Set when using the include directive in kitty.conf. Can take values: ``linux``, ``macos``, ``bsd``. + +.. envvar:: KITTY_HOLD + + Set to ``1`` when kitty is running a shell because of the ``--hold`` flag. Can + be used to specialize shell behavior in the shell rc files as desired. diff --git a/kitty/utils.py b/kitty/utils.py index 4b9df34d4..c138ce336 100644 --- a/kitty/utils.py +++ b/kitty/utils.py @@ -1185,7 +1185,7 @@ def cmdline_for_hold(cmd: Sequence[str] = (), opts: Optional['Options'] = None) ksi = ' '.join(opts.shell_integration) import shlex shell = shlex.join(resolved_shell(opts)) - return [kitten_exe(), 'run-shell', f'--shell={shell}', f'--shell-integration={ksi}'] + list(cmd) + return [kitten_exe(), 'run-shell', f'--shell={shell}', f'--shell-integration={ksi}', '--env=KITTY_HOLD=1'] + list(cmd) def safe_mtime(path: str) -> Optional[float]: