mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.95k stars 716 forks source link

Use Python API to control iTerm2 #3211

Open lrworth opened 4 years ago

lrworth commented 4 years ago

iTerm2 has deprecated its Applescript API in favour of its Python API. Running a Python daemon and controlling windows with custom escape sequences appears to be quite a lot faster than using osascript. Let's replace the existing iterm integration with one using this new method.

This is mainly a placeholder issue because I would like to do it myself.

eraserhd commented 4 years ago

There's some cool stuff in here, but I'm worried about dependencies. I don't have a version of python3 it likes, and it wants to install its own into the application folder. It says I can install my own python and iterm2 module, but the python scripts need to be invoked with the correct python3 binary.

Also, the python library uses websocket+protobuf, not custom escape sequences. If custom escape sequences are available, that would be a lot less dependencies to manage. I'm not sure there's a way to get Kakoune to pass through some custom escapes right now, but that seems like an easy problem to solve with some kind of tty expansion.

lrworth commented 4 years ago

The UX is a little clunky the first time you need to use the python API, but it does do everything mostly automatically. Maybe this will be better provided as a plugin rather than a PR for the first instance.

As for how it would work, this example will provide clarification.