Open dusty-phillips opened 1 year ago
Seems reasonable, but I don't know enough about kitty or the ssh kitten to offer any suggestions. I'd be more than happy to accept a pull request, though, if it's something you would like to work on.
I’ve poked through the ssh sources and can’t find anything immediately applicable, but it feels like the plumbing is there to support it. Will try to do a deeper dive if I can find the time.
See discussion here which should give you some help: https://github.com/kovidgoyal/kitty/discussions/6229
Tested a heavily customized (my titles use a lot of aliases...) variation on gzagatti's post and was able to get pass_keys.py to detect a vim window inside ssh.
However, now neighbouring_window.py, when called from the vim session inside ssh, is not able to pass the command out to kitty outside ssh. Will try to debug further this weekend.
I know what's happening.
The problem is that now your keys are being passed to nvim. However when you issue the command from nvim, the command fails. Under the hood, nvim is trying to call neighboring_window.py
. You can emulate this call in nvim from the command line:
> :echo system("kitty @ kitten neighboring_window.py bottom")
If your kitty.conf
file has allow_remote_control yes
, then you'll likely get an error:
Traceback (most recent call last):
File "runpy.py", line 197, in _run_module_as_main
File "runpy.py", line 87, in _run_code
File "kitty_main.py", line 7, in <module>
File "kitty/entry_points.py", line 206, in main
File "kitty/entry_points.py", line 23, in remote_control
File "kitty/remote_control.py", line 504, in main
File "kitty/remote_control.py", line 314, in do_io
File "kitty/utils.py", line 528, in __enter__
OSError: Failed to open controlling terminal: /dev/tty (identified with ctermid()) with error: No such device or address
Press ENTER or type command to continue
The problem here is that nvim does not spawn commands connected to the tty. Check this discussion thread.
So what can you do? One option is to reverse bind the kitty socket to the remote server:
> kitty +kitten ssh ids-dgx1 -R ${KITTY_LISTEN_ON#unix:}:${KITTY_LISTEN_ON#unix:}
Then set the env variable KITTY_LISTEN_ON
to point to the socket in the remote server. With all that up, you'll have the plugin working.
In that case, you might want to set allow_remote_control socket-only
in your kitty.conf
file.
Please let me know if you find a simpler setup.
Also see issue mrjones2014/smart-splits.nvim#103. You'll likely want to use user var as kitty has recently introduced it.
Just FYI, some recent additions to kitty to make this easier:
The ssh kitten can now automatically forward the kitty remote control socket by setting forward_remote_control yes in ~/.config/kitty/ssh.conf
And you dont need neighboring_window.py anymore, you can just do
kitten @ focus-window --match neighbor:left
Change left to right/top/bottom as needed. You will need to run from master/nightly for these till the next kitty release.
That's great! I'll test once the new Kitty version comes out.
Did you end up getting a working solution with the new kitty? I tried following along the various threads and discussions you were on but wasn't able to recreate something working myself 😔
No, at the end I just kept my setup above because it was working pretty well already. I also did not quite figure out how to use the new feature.
It works partially for me. The navigation between Kitty panes still works, but not inside Neovim 😢. All moves inside neovim are gone on SSH, UP, RIGHT, DOWN, and LEFT.
I often ssh into a system and run neovim inside the ssh terminal. As a result,
pass_keys.py
is unable to determine whether the ssh window is a vim window or not.I use
kitty + kitten ssh
to ssh into the target system. The foreground_process contains a long and complex ssh command. But since I used kitty`s ssh kitten, I'm wondering if it might be possible to ask it what process is running inside the ssh session and let the keys pass through in that case. Know of any way to support this?