Avoid needing to exec kitty to get manual shell integration

This commit is contained in:
Kovid Goyal 2021-11-08 11:37:50 +05:30
parent 4841502959
commit 0c160eab7b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 20 additions and 15 deletions

View File

@ -116,6 +116,11 @@ Variables that kitty sets when running child programs
Path to a directory containing the kitty terminfo database.
.. envvar:: KITTY_INSTALLATION_DIR
Path to the kitty installation directory.
.. envvar:: COLORTERM
Set to the value ``truecolor`` to indicate that kitty supports 16 million
@ -152,4 +157,5 @@ Variables that kitty sets when running child programs
.. envvar:: KITTY_SHELL_INTEGRATION
Set when enabling :ref:`shell_integration`.
Set when enabling :ref:`shell_integration`. It is automatically removed by
the shell integration scripts.

View File

@ -140,31 +140,29 @@ want to setup shell integration for a remote system over SSH, in
Then in your shell's rc file, add the lines:
.. tab:: bash/zsh
.. tab:: bash
.. code-block:: sh
export KITTY_SHELL_INTEGRATION="enabled"
source $(kitty +runpy "from kitty.shell_integration import script_path; print(script_path())")
source "$KITTY_INSTALLATION_DIR/shell-integration/kitty.bash"
.. tab:: zsh
.. code-block:: sh
export KITTY_SHELL_INTEGRATION="enabled"
source "$KITTY_INSTALLATION_DIR/shell-integration/kitty.zsh"
.. tab:: fish
.. code-block:: fish
set --global KITTY_SHELL_INTEGRATION enabled
set --path --local kitty_paths (kitty +runpy 'from kitty.shell_integration import print_fish_paths; print_fish_paths()')
source kitty_paths[2]
set --prepend fish_complete_path kitty_paths[1]
set --erase kitty_paths
source "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_conf.d/kitty-shell-integration.fish"
set --prepend fish_complete_path "$KITTY_INSTALLATION_DIR/shell-integration/fish/vendor_completions.d"
You can get the path to the directory containing the various shell integration
scripts by looking at the directory displayed by:
.. code-block:: sh
kitty +runpy "from kitty.constants import *; print(shell_integration_dir)"
The value of :envvar:`KITTY_SHELL_INTEGRATION` is the same as that for
:opt:`shell_integration`, except if you want to disable shell integration
completely, in which case simply do not set the

View File

@ -12,7 +12,7 @@ from typing import (
import kitty.fast_data_types as fast_data_types
from .constants import is_macos, shell_path, terminfo_dir
from .constants import is_macos, kitty_base_dir, shell_path, terminfo_dir
from .types import run_once
try:
@ -229,6 +229,7 @@ class Child:
tdir = checked_terminfo_dir()
if tdir:
env['TERMINFO'] = tdir
env['KITTY_INSTALLATION_DIR'] = kitty_base_dir
opts = fast_data_types.get_options()
if opts.shell_integration != 'disabled':
from .shell_integration import modify_shell_environ