kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
23.83k stars 961 forks source link

`$KITTY_SHELL_INTEGRATION` is not set correctly in some cases #6783

Closed musjj closed 10 months ago

musjj commented 10 months ago

Describe the bug When using kitty @ launch or running sub-shells, $KITTY_SHELL_INTEGRATION is not set correctly when shell_integration is no-rc. Is this expected behavior?

To Reproduce Steps to reproduce the behavior:

  1. Put this in your ~/.zshrc:
    if test -n "$KITTY_INSTALLATION_DIR"; then
    echo "'$KITTY_SHELL_INTEGRATION'"
    autoload -Uz -- "$KITTY_INSTALLATION_DIR"/shell-integration/zsh/kitty-integration
    kitty-integration
    unfunction kitty-integration
    fi
  2. Open a new split, your current shell_integration option will be echoed correctly
  3. Run kitty @ launch --hold echo "hello world", an empty '' will be echoed
  4. Run $SHELL for the same result
Environment details ``` kitty 0.30.1 created by Kovid Goyal Linux humbug 6.1.60 #1-NixOS SMP PREEMPT_DYNAMIC Wed Oct 25 10:03:17 UTC 2023 x86_64 <<< Welcome to NixOS 23.11.20231029.0cbe9f6 (x86_64) - /dev/tty >>> Run 'nixos-help' for the NixOS manual. DISTRIB_CODENAME=tapir DISTRIB_DESCRIPTION="NixOS 23.11 (Tapir)" DISTRIB_ID=nixos DISTRIB_RELEASE="23.11" LSB_VERSION="23.11 (Tapir)" Running under: X11 Frozen: False Paths: kitty: /nix/store/aixcg8gakqa1km4sd3ynbrbslcr9n580-kitty-0.30.1/bin/kitty base dir: /nix/store/aixcg8gakqa1km4sd3ynbrbslcr9n580-kitty-0.30.1/lib/kitty extensions dir: /nix/store/aixcg8gakqa1km4sd3ynbrbslcr9n580-kitty-0.30.1/lib/kitty/kitty system shell: /run/current-system/sw/bin/zsh Loaded config files: /tmp/kitty.conf Config options different from defaults: allow_remote_control yes shell_integration frozenset({'no-rc'}) Important environment variables seen by the kitty process: PATH /nix/store/aixcg8gakqa1km4sd3ynbrbslcr9n580-kitty-0.30.1/bin:/nix/store/wimlq5g8jdqk3i2wk7h31rdxhjyhahv7-imagemagick-7.1.1-21/bin:/nix/store/2kridj093jlhc9x1y5nvn4j35lgigzid-ncurses-6.4-dev/bin:/nix/store/ffll6glz3gwx342z0ch8wx30p5cnqz1z-python3-3.11.5/bin:/nix/store/n23y43qvhwqhs1l3f9wkivk51mjzcdz7-python3.11-qtile-0.23.0/bin:/nix/store/ixjfb86ick641wd3pn74a2qqiqiry9ir-cairo-1.16.0-dev/bin:/nix/store/kbbyb2xs80qwxdj2mrp3p1vq6a0g5fkn-freetype-2.13.2-dev/bin:/nix/store/w1mar48lwkavwy64mvj567lwaqnm2l11-bzip2-1.0.8-bin/bin:/nix/store/92ic764n8wdqmjc16pvxdnw91wq5xiaq-brotli-1.1.0/bin:/nix/store/5lywvpn9w0914caa3n1ib92xlahb0hvl-libpng-apng-1.6.40-dev/bin:/nix/store/ir6g787nab1xb62pw6yp1qs62qjks3h0-fontconfig-2.14.2-bin/bin:/nix/store/4rrd2p4db74nf732nm98bhd47zqg5k2d-expat-2.5.0-dev/bin:/nix/store/9mfjj1p9xkx1dzpbd20jfd5xbj0l5gan-glib-2.76.4-dev/bin:/nix/store/72xph8fn1a1w3ilszxdm0l9npimpa1sm-gettext-0.21.1/bin:/nix/store/2z3arz5ni43qdkbk95pmkl25kf77ww3i-glib-2.76.4-bin/bin:/nix/store/z5yw9m497n1l6ndcwllka5sbjd9f66vg-wireless-tools-30.pre9/bin:/nix/store/bhfnpk1xy5b3jj62gxr5r2vig2f5i1rl-python3.11-pywayland-0.4.17/bin:/run/wrappers/bin:/home/$USER/.nix-profile/bin:/nix/profile/bin:/home/$USER/.local/state/nix/profile/bin:/etc/profiles/per-user/$USER/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/home/$USER/.zsh/plugins/fzf-tab-completion:/home/$USER/.zsh/plugins/fast-syntax-highlighting:/home/$USER/.zsh/plugins/zsh-autopair LANG en_US.UTF-8 EDITOR hx SHELL /run/current-system/sw/bin/zsh GLFW_IM_MODULE ibus DISPLAY :0 USER $USER XCURSOR_SIZE 16 XDG_CONFIG_DIRS /etc/xdg:/home/$USER/.nix-profile/etc/xdg:/nix/profile/etc/xdg:/home/$USER/.local/state/nix/profile/etc/xdg:/etc/profiles/per-user/$USER/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg XDG_SESSION_PATH /org/freedesktop/DisplayManager/Session0 XDG_SEAT seat0 XDG_SESSION_DESKTOP none+dummy XDG_SESSION_TYPE x11 XDG_GREETER_DATA_DIR /var/lib/lightdm-data/$USER XDG_CURRENT_DESKTOP none+dummy XDG_SEAT_PATH /org/freedesktop/DisplayManager/Seat0 XDG_SESSION_CLASS user XDG_VTNR 7 XDG_SESSION_ID 2 XDG_RUNTIME_DIR /run/user/1000 XDG_DATA_DIRS /nix/store/q7l23iy0rjh3y5vlbl47lsk8kgy6zxh6-desktops/share:/home/$USER/.nix-profile/share:/nix/profile/share:/home/$USER/.local/state/nix/profile/share:/etc/profiles/per-user/$USER/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share ```

Additional context My config:

shell_integration no-rc
allow_remote_control yes
kovidgoyal commented 10 months ago

shell integration is only set when you are running the default shell, if you are running random commands there is no expectation of shell integration working. If you want to do that do it something like this:

launch sh -c "my random command; kitten run-shell"

that will leave you with a shell with shell integration enabled.

musjj commented 10 months ago

Alright :+1: So, you should always set KITTY_SHELL_INTEGRATION manually in your rc file, if you want to ensure that integration always works right?

kovidgoyal commented 10 months ago

See https://sw.kovidgoyal.net/kitty/shell-integration/#manual-shell-integration