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

Add kitty terminal support #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ There are two main keybindings:

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).

1. Kitty
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:

1. Add this configuration to your `SendCode.sublime-settings`:
```json
"prog": "kitty",
"kitty": {
"path": "/path/to/kitty",
"socket": "unix:/tmp/kitty",
}
```
2. Add `allow_remote_control socket-only` to your `kitty.conf`
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.
4. Double check that `echo $KITTY_LISTEN_ON` is pointing to the same socket as defined in your Sublime Text configuration.

### Custom Keybindings

Expand Down
7 changes: 7 additions & 0 deletions code_sender/kitty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from os import system
from shlex import quote

def send_to_kitty(cmd, path, socket):
template = "{path} @ --to {socket} send-text --match state:focused {cmd}\r"
command = template.format(path=path, socket=socket, cmd=quote(cmd))
system(command)
7 changes: 7 additions & 0 deletions code_sender/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from .safari import send_to_safari_jupyter, send_to_safari_rstudio
from .sublimerepl import send_to_sublimerepl
from .terminus import send_to_terminus
from .kitty import send_to_kitty
from .clipboard import clipboard


Expand Down Expand Up @@ -86,6 +87,10 @@ def send_to_rstudio(self, cmd):
else:
send_to_rstudio(cmd)

def send_to_kitty(self, cmd):
kitty = self.settings.get("kitty", "kitty")
send_to_kitty(cmd, kitty["path"], kitty["socket"])

def send_text(self, cmd):
cmd = cmd.rstrip()
cmd = cmd.expandtabs(self.view.settings().get("tab_size", 4))
Expand Down Expand Up @@ -116,6 +121,8 @@ def send_text(self, cmd):
self.send_to_terminus(cmd)
elif prog == "rstudio":
self.send_to_rstudio(cmd)
elif prog == "kitty":
self.send_to_kitty(cmd)
else:
sublime.message_dialog("%s is not supported for current syntax." % prog)

Expand Down