kovidgoyal / kitty

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

Kitten @ kitten clipboard/icat etc. doesn't run #7585

Closed AniAggarwal closed 2 months ago

AniAggarwal commented 2 months ago

Describe the bug When running kitten @ and then a specific kitten, the following results.

$ kitten @ --to=$KITTY_LISTEN_ON kitten clipboard                                   
Traceback (most recent call last):
  File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command
  File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd
  File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty
  File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata
  File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler
  File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module
AttributeError: module 'kittens.clipboard.main' has no attribute 'main'

Error: module 'kittens.clipboard.main' has no attribute 'main'

The use case is to use the --to flag with a kitten clipboard, using kitten @ rather than kitty @ for use on a remote machine.

To Reproduce Steps to reproduce the behavior:

  1. Run kitty @ kitten clipboard or kitten @ kitten clipboard or with the icat kitten.
    
    ❯ kitten @ kitten clipboard
    Traceback (most recent call last):
    File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command
    File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd
    File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty
    File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata
    File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler
    File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module
    AttributeError: module 'kittens.clipboard.main' has no attribute 'main'

Error: module 'kittens.clipboard.main' has no attribute 'main'

~ ❯ kitty @ kitten clipboard Traceback (most recent call last): File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module AttributeError: module 'kittens.clipboard.main' has no attribute 'main'

Error: module 'kittens.clipboard.main' has no attribute 'main'

~ ❯ kitten @ kitten icat
Traceback (most recent call last): File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module AttributeError: module 'kittens.icat.main' has no attribute 'main'

Error: module 'kittens.icat.main' has no attribute 'main'

~ ❯ kitty @ kitten icat Traceback (most recent call last): File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module AttributeError: module 'kittens.icat.main' has no attribute 'main'

Error: module 'kittens.icat.main' has no attribute 'main'


**Environment details**

kitty 0.35.0 (beb42d571b) created by Kovid Goyal Darwin 80a9972fb221 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:13:18 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6030 arm64 ProductName: macOS ProductVersion: 14.5 BuildVersion: 23F79 OpenGL: '4.1 Metal - 88.1' Detected version: 4.1 Frozen: True Paths: kitty: /Applications/kitty.app/Contents/MacOS/kitty base dir: /Applications/kitty.app/Contents/Resources/kitty extensions dir: /Applications/kitty.app/Contents/Resources/Python/lib/kitty-extensions system shell: /bin/zsh Loaded config files: /Users/aniagg/.config/kitty/kitty.conf

Config options different from defaults: allow_cloning yes allow_remote_control yes clipboard_control ('write-clipboard', 'write-primary', 'read-clipboard', 'read-primary') editor /opt/homebrew/bin/nvim enable_audio_bell False font_family FiraCode Nerd Font font_size 14.0 hide_window_decorations 2 linux_display_server wayland listen_on unix:/tmp/mykitty macos_option_as_alt 3 paste_actions frozenset({'confirm-if-large', 'replace-dangerous-control-codes'}) scrollback_lines 20000 tab_bar_style powerline wayland_titlebar_color 673985538 Added shortcuts: cmd+l → clear_terminal to_cursor_scroll active ctrl+enter → send_text all \x00\r ctrl+h → [--when-focus-on=var:IS_NVIM]no-op, neighboring_window left ctrl+j → [--when-focus-on=var:IS_NVIM]no-op, neighboring_window down ctrl+k → [--when-focus-on=var:IS_NVIM]no-op, neighboring_window up ctrl+l → [--when-focus-on=var:IS_NVIM]no-op, neighboring_window right ctrl+opt+enter → send_text normal clone-in-kitty\r shift+cmd+h → [--when-focus-on=var:IS_NVIM]no-op, kitten relative_resize.py left 3 shift+cmd+j → [--when-focus-on=var:IS_NVIM]no-op, kitten relative_resize.py down 3 shift+cmd+k → [--when-focus-on=var:IS_NVIM]no-op, kitten relative_resize.py up 3 shift+cmd+l → [--when-focus-on=var:IS_NVIM]no-op, kitten relative_resize.py right 3 shift+opt+enter → new_window Removed shortcuts: cmd+, → edit_config_file cmd+enter → new_window cmd+h → hide_macos_app cmd+k → clear_terminal to_cursor active cmd+m → minimize_macos_window cmd+n → new_os_window cmd+q → quit cmd+t → new_tab cmd+w → close_tab ctrl+cmd+, → load_config_file ctrl+cmd+f → toggle_fullscreen opt+cmd+h → hide_macos_other_apps opt+cmd+r → clear_terminal reset active opt+cmd+s → toggle_macos_secure_keyboard_entry shift+cmd+/ → open_url https://sw.kovidgoyal.net/kitty/ shift+cmd+[ → previous_tab shift+cmd+] → next_tab shift+cmd+d → close_window shift+cmd+w → close_os_window Changed shortcuts: kitty_mod+[ → previous_tab kitty_mod+] → next_tab kitty_mod+enter → launch --cwd=current kitty_mod+f → launch --type=overlay --stdin-source=@screen_scrollback /usr/bin/fzf --no-sort --no-mouse --exact -i kitty_mod+t → new_tab_with_cwd Colors: active_border_color #8c00ff
background #282c34
color0 #20232a
color1 #e86671
color10 #98c379
color11 #e0af68
color12 #61afef
color13 #c678dd
color14 #56b6c2
color15 #abb2bf
color16 #d19a66
color17 #f65866
color2 #98c379
color3 #e0af68
color4 #61afef
color5 #c678dd
color6 #56b6c2
color7 #798294
color8 #5c6370
color9 #e86671
cursor #abb2bf
foreground #abb2bf
inactive_border_color #b0b0b0
inactive_tab_background #282c34
inactive_tab_foreground #5c6370
selection_background #393f4a
selection_foreground #abb2bf
url_color #98c379

Important environment variables seen by the kitty process: PATH removed for security LANG en_US.UTF-8 SHELL /bin/zsh USER aniagg


**Additional context**
Using no config doesn't allow this to work since remote control is disabled. 
Running as follows:
`kitty --config NONE -o allow_remote_control=yes` results in same errors:

❯ kitten @ kitten clipboard
Traceback (most recent call last): File "lib/python3.12/kitty/boss.py", line 707, in _execute_remote_command File "lib/python3.12/kitty/remote_control.py", line 247, in handle_cmd File "lib/python3.12/kitty/rc/kitten.py", line 41, in response_from_kitty File "lib/python3.12/kitty/boss.py", line 1894, in run_kitten_with_metadata File "lib/python3.12/kittens/runner.py", line 71, in create_kitten_handler File "lib/python3.12/kittens/runner.py", line 63, in import_kitten_main_module AttributeError: module 'kittens.clipboard.main' has no attribute 'main'

Error: module 'kittens.clipboard.main' has no attribute 'main'

kovidgoyal commented 2 months ago

You want to use the clipboard kitten you simply do

kitten clipboard

It works fine over SSH. https://sw.kovidgoyal.net/kitty/kittens/clipboard/

AniAggarwal commented 2 months ago

I'd like to use kitten clipboard as my neovim clipboard so that I can use it over ssh like normal but neovim doesn't let you use kitten clipboard calls through it since it doesn't set up a tty. Based on the previous threads you had recommended using the --to flag and use listen on so thats why I am attempting to use this in this manner.

Is there a better way to make clipboard over ssh with (neo)vim work?

kovidgoyal commented 2 months ago

Use up to date neovim where it supports OSC 52 natively which works over ssh natively.

AniAggarwal commented 2 months ago

The issue with OSC 52 is that it doesn't seem to actually copy across my ssh for whatever reason from remote machine back to local machine buffer. AFAIK it seems like it isn't a fully fledged clipboard provider and I can't expect more from it? I realize I could setup something like lemonade but I'd like to stay in the kitty ecosystem if possible since it does practically everything else so well :)

kovidgoyal commented 2 months ago

The clipboard kitten also uses OSC 52. So there is no way it can not be working, if the kitten is working. If it isnt working in nvim you need to ask the nvim developers for help.

AniAggarwal commented 2 months ago

Huh, I didn't know that. Got it. Perhaps the error I encountered though should have a more friendly error message so others know not to use the kitten @ in this way? Thanks again.