Move the bash integration script into its own dir
This matches the other shells and might be useful someday if bash ever gets a way for the invoking process to inject code into it. Also use KITTY_INSTALLATION_DIR when loading the bash integration code.
This commit is contained in:
parent
276ed7263c
commit
9441cf15c3
@ -171,7 +171,7 @@ code used for each shell below:
|
||||
|
||||
.. tab:: bash
|
||||
|
||||
.. literalinclude:: ../shell-integration/kitty.bash
|
||||
.. literalinclude:: ../shell-integration/bash/kitty.bash
|
||||
:language: bash
|
||||
|
||||
.. raw:: html
|
||||
@ -201,16 +201,16 @@ Then in your shell's rc file, add the lines:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
if [[ ! -z "$KITTY_INSTALLATION_DIR" ]]; then
|
||||
if test -n "$KITTY_INSTALLATION_DIR"; then
|
||||
export KITTY_SHELL_INTEGRATION="enabled"
|
||||
source "$KITTY_INSTALLATION_DIR/shell-integration/kitty.bash"
|
||||
source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
|
||||
fi
|
||||
|
||||
.. tab:: zsh
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
if [[ ! -z "$KITTY_INSTALLATION_DIR" ]]; then
|
||||
if test -n "$KITTY_INSTALLATION_DIR"; then
|
||||
export KITTY_SHELL_INTEGRATION="enabled"
|
||||
source "$KITTY_INSTALLATION_DIR/shell-integration/zsh/kitty.zsh"
|
||||
fi
|
||||
|
||||
@ -13,7 +13,7 @@ from .utils import log_error, resolved_shell
|
||||
|
||||
posix_template = '''
|
||||
# BEGIN_KITTY_SHELL_INTEGRATION
|
||||
if test -e {path}; then source {path}; fi
|
||||
if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/{path}"; then source "$KITTY_INSTALLATION_DIR/{path}"; fi
|
||||
# END_KITTY_SHELL_INTEGRATION
|
||||
'''
|
||||
|
||||
@ -35,11 +35,7 @@ def setup_integration(shell_name: str, rc_path: str, template: str = posix_templ
|
||||
import re
|
||||
rc_path = os.path.realpath(rc_path)
|
||||
rc = safe_read(rc_path)
|
||||
home = os.path.expanduser('~') + '/'
|
||||
path = os.path.join(shell_integration_dir, f'kitty.{shell_name}')
|
||||
if path.startswith(home):
|
||||
path = '$HOME/' + path[len(home):]
|
||||
integration = template.format(path=f'"{path}"')
|
||||
integration = template.format(path=f"shell-integration/{shell_name}/kitty.{shell_name}")
|
||||
newrc = re.sub(
|
||||
r'^# BEGIN_KITTY_SHELL_INTEGRATION.+?^# END_KITTY_SHELL_INTEGRATION',
|
||||
'', rc, flags=re.DOTALL | re.MULTILINE)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user