Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support kitty's new shell integration #134

Closed
maximbaz opened this issue Aug 24, 2021 · 12 comments
Closed

Support kitty's new shell integration #134

maximbaz opened this issue Aug 24, 2021 · 12 comments

Comments

@maximbaz
Copy link
Contributor

Hi there 👋

I think you will find this super interesting, I certainly did: kovidgoyal/kitty#3948

At a minimum, I think we should support sourcing the integration script by default (currently kitty modifies .zshrc to add its stuff, but this is configurable).

Native integration does some things that z4h also does (e.g. managing terminal title), and if we leave things as is (kitty's file being sourced last) it takes priority over z4h's settings - by sourcing it internally I suppose this will be fixed too.

Jump to the previous/next prompt in the scrollback (ctrl+shit+z/ctrl+shift+x)

This is the only thing that doesn't work for me with z4h (with .zshrc being just three lines below, and empty kitty.conf), it would be super nice to get this supported.

zstyle ':z4h:' start-tmux no
z4h init || return
if test -e "$HOME/kitty/shell-integration/kitty.zsh"; then source "$HOME/kitty/shell-integration/kitty.zsh"; fi

tmux integration might be another thing that needs considering, but honestly speaking I haven't been using it for a good while now, due to me using too often Ctrl+Shift+N to start new terminal in the same folder, and that sway issue where in a freshly new opened window, prompt appears not always in the bottom but in random locations in the middle.

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

Thanks for the heads up.

Please try the following:

  1. Add at the top of ~/.zshrc:
    zstyle ':z4h:' iterm2-integration yes
  2. Add at the bottom of ~/.zshrc right before the snipped that Kitty adds:
    unset KITTY_SHELL_INTEGRATION

Both of these changes are safe to do regardless of which terminal and OS you are using. The first change enables iTerm2 integration, which now should also double as Kitty integration. The second change makes native Kitty integration a no-op (see the top of ~/kitty/shell-integration/kitty.zsh).

Let me know how this works for you.

@maximbaz
Copy link
Contributor Author

Just to confirm, did you perhaps forget to git push the v5 branch, that would make iterm2 integration include kitty?

As for the second point, yep makes sense, for info it's also possible to disable it in kitty's config, such that kitty won't even attempt to modify .zshrc: https://github.com/kovidgoyal/kitty/blob/master/docs/shell-integration.rst#manual-shell-integration

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

Just to confirm, did you perhaps forget to git push the v5 branch, that would make iterm2 integration include kitty?

It's supposed to just work without any changes in z4h. Does it?

As for the second point, yep makes sense, for info it's also possible to disable it in kitty's config, such that kitty won't even attempt to modify .zshrc: https://github.com/kovidgoyal/kitty/blob/master/docs/shell-integration.rst#manual-shell-integration

Yep, I saw that. I would recommend doing both. The unset line is for safety so that even if kitty modifies your zshrc, it won't break.

@maximbaz
Copy link
Contributor Author

It's supposed to just work without any changes in z4h. Does it?

Ah, then no, it doesn't happen. I was trying to figure out how this should happen, so that I could provide more useful debugging info...

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

How are you checking whether it works? What exactly doesn't work?

I did try it before asking you to try. It works for me. E.g., print hello followed by Ctrl+Shift+G opens hello in pager. I didn't disable use shell_integration disabled and haven't tried it with this option (I'm wary because I don't want to disable shell integration; I only want to disable modifying zshrc but there is no option for that).

@maximbaz
Copy link
Contributor Author

Ahh sorry, what doesn't work is the beam cursor shape, I naively used that as my quick test - without z4h, cursor has a vertical bar shape, with z4h it's a regular rectangle. The rest of the things work as expected.

In fact things like Ctrl+Shift+G work equally well with both shell_integration disabled and shell_integration no-rc (is the latter what you are looking for?) when enabling iterm2-integration flag.

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

I see. It's all working as expected then. It should also work over ssh by the way (unlike the native kitty integration). And over tmux (likewise).

That thing with the cursor is not specific to kitty. It can be implemented in z4h for all terminals if that's what you want. It's such a weird feature though. Why would you want one cursor within zle and a different cursor everywhere else? I use beam everywhere because it's obviously the best. You can likely configure kitty to use beam.

@maximbaz
Copy link
Contributor Author

OK thanks for clarifying! And awesome that it works over ssh/tmux!

Regarding cursors, I see. It's not that I wanted another cursor shape in particular, it was my mistake that I saw a different cursor shape with and without sourcing kitty's script, and incorrectly assumed that the entire integration is not working.

You are right by the way that it's possible to configure kitty to use beam everywhere, I'll give it a go 🙂

Closing as everything seems to be good, thanks for your quick help as usual.

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

Shell integration was also supposed to fix the issue with prompt when resizing the terminal window. It doesn't work though. I still get artifacts on resizing. I haven't looked yet why that happens (I'm frankly not motivated to do that because I don't care about this).

@maximbaz
Copy link
Contributor Author

Cannot say that I do either 😅 Even if they do appear, it's quite rare, or I just don't notice...

@kovidgoyal
Copy link

I only want to disable modifying zshrc but there is no option for that).

Yes, there is,

shell_integration=enabled no-rc

@romkatv
Copy link
Owner

romkatv commented Aug 25, 2021

@kovidgoyal Got it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants