Kitty: How to execute a command in another window?

Created on 13 Mar 2019  路  2Comments  路  Source: kovidgoyal/kitty

Please re-direct me to the correct place to ask questions if this is not the right spot.

I've searched the documentation and I know about kitty @ send-text. So far what I've been able to do is _send_ the command to another window, but I can't get it to execute from another window. That is, I have to cycle to that window and press the enter key.

My use case is while using vim-test, I want to use a custom strategy that sends the test command to another window and runs it. So far, using Dispatch! and kitty @ send-text --match title:api cmd I've managed to send the text to the window but I still have to cycle to the window to press enter.

Is what I'm trying to do possible? Thank you in advance.

Most helpful comment

@arjun1995 did you get this working? Cause right now, when I run commands from vim (or neovim) with Tim Pope's Dispatch I get this error:

|| Traceback (most recent call last):
||   File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
||     "__main__", mod_spec)
||   File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
||     exec(code, run_globals)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 117, in <module>
||     main()
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 113, in main
||     func(sys.argv[1:])
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 22, in remote_control
||     main(args)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/remote_control.py", line 175, in main
||     response = do_io(global_opts.to, send, no_response)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/remote_control.py", line 119, in do_io
||     with io:
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/utils.py", line 369, in __enter__
||     self.tty_fd, self.original_termios = open_tty(True)
|| OSError: [Errno 6] Device not configured

Strangely, in vim, running commands like :!kitty @ new-window works, but it doesn't in neovim.

Got any clue about what's going on?

macOS Mojave 10.14.5
Kitty 0.14.2
Vim 8.1 (patches 1-1550)
Neovim v0.4.0-1071-ge28a7a366

All 2 comments

Simply send the enter key as well. Something like

\x0d or \\x0d should do the trick depending on your shell's escape codes.

@arjun1995 did you get this working? Cause right now, when I run commands from vim (or neovim) with Tim Pope's Dispatch I get this error:

|| Traceback (most recent call last):
||   File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
||     "__main__", mod_spec)
||   File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
||     exec(code, run_globals)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 117, in <module>
||     main()
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 113, in main
||     func(sys.argv[1:])
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/__main__.py", line 22, in remote_control
||     main(args)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/remote_control.py", line 175, in main
||     response = do_io(global_opts.to, send, no_response)
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/remote_control.py", line 119, in do_io
||     with io:
||   File "/Applications/kitty.app/Contents/MacOS/../Frameworks/kitty/kitty/utils.py", line 369, in __enter__
||     self.tty_fd, self.original_termios = open_tty(True)
|| OSError: [Errno 6] Device not configured

Strangely, in vim, running commands like :!kitty @ new-window works, but it doesn't in neovim.

Got any clue about what's going on?

macOS Mojave 10.14.5
Kitty 0.14.2
Vim 8.1 (patches 1-1550)
Neovim v0.4.0-1071-ge28a7a366

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nudin picture Nudin  路  3Comments

metalelf0 picture metalelf0  路  4Comments

mihaicristiantanase picture mihaicristiantanase  路  3Comments

Jomik picture Jomik  路  4Comments

Askannz picture Askannz  路  3Comments