Skip to content

Commit 57c5ae7

Browse files
committed
Add kitty terminal support
1 parent 6775b40 commit 57c5ae7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ There are two main keybindings:
7777

7878
Most likely you haven't enabled JavaScript for AppleScript. Check the option "Allow JavaScript from Apple Events" in the `Develop` menu (the `Develope` menu needs to be enabled in the preferences).
7979

80+
1. Kitty
81+
All text commands from Sublime Text to Kitty are sent through the unix socket, so it is vital to have correct configuration on both sides. Please follow these steps:
82+
83+
1. Add this configuration to your `SendCode.sublime-settings`:
84+
```json
85+
"kitty": {
86+
"path": "/path/to/kitty",
87+
"socket": "unix:/tmp/kitty",
88+
}
89+
```
90+
2. Add `allow_remote_control socket-only` to your `kitty.conf`
91+
3. Start kitty with `--listen-on=unix:/tmp/kitty` flag. If you are using MacOS you can conveniently put it into `<kitty config dir>/macos-launch-services-cmdline` file.
92+
4. Double check that `echo $KITTY_LISTEN_ON` is pointing to the same socket as defined in your Sublime Text configuration.
8093

8194
### Custom Keybindings
8295

code_sender/kitty/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from os import system
2+
from shlex import quote
3+
4+
def send_to_kitty(cmd, path, socket):
5+
template = "{path} @ --to {socket} send-text {cmd}\r"
6+
command = template.format(path=path, socket=socket, cmd=quote(cmd))
7+
system(command)

code_sender/sender.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from .safari import send_to_safari_jupyter, send_to_safari_rstudio
1616
from .sublimerepl import send_to_sublimerepl
1717
from .terminus import send_to_terminus
18+
from .kitty import send_to_kitty
1819
from .clipboard import clipboard
1920

2021

@@ -86,6 +87,10 @@ def send_to_rstudio(self, cmd):
8687
else:
8788
send_to_rstudio(cmd)
8889

90+
def send_to_kitty(self, cmd):
91+
kitty = self.settings.get("kitty", "kitty")
92+
send_to_kitty(cmd, kitty["path"], kitty["socket"])
93+
8994
def send_text(self, cmd):
9095
cmd = cmd.rstrip()
9196
cmd = cmd.expandtabs(self.view.settings().get("tab_size", 4))
@@ -116,6 +121,8 @@ def send_text(self, cmd):
116121
self.send_to_terminus(cmd)
117122
elif prog == "rstudio":
118123
self.send_to_rstudio(cmd)
124+
elif prog == "kitty":
125+
self.send_to_kitty(cmd)
119126
else:
120127
sublime.message_dialog("%s is not supported for current syntax." % prog)
121128

0 commit comments

Comments
 (0)