
iTerm2 beta adds Python API - 20after4
https://iterm2.com/python-api/
======
j88439h84
Kitty terminal has a Python API too, and it's got images and high performance,
etc.

[https://sw.kovidgoyal.net/kitty/](https://sw.kovidgoyal.net/kitty/)

~~~
daveFNbuck
I tried switching to Kitty last year, but then it stopped working properly
with the OSX 10.14 release. It turns out this was a known issue from the beta,
but the author decided not to do anything about it until the release [1]. I
can't rely on a terminal that's maintained like that.

[1]
[https://github.com/kovidgoyal/kitty/issues/887#issuecomment-...](https://github.com/kovidgoyal/kitty/issues/887#issuecomment-419138736)

~~~
photonios
Give Alacritty [1] a try. I am very happy with its performance, it just feels
fast and solid. The difference in latency is really noticeable to me compared
to iTerm2 or Terminal.app. Alacritty just feels significantly faster.

[1] [https://github.com/jwilm/alacritty](https://github.com/jwilm/alacritty)

Disclaimer: I am not associated with the project in any way. Just a fan.

~~~
daveFNbuck
People keep talking about the obvious latency difference. I don't notice any
latency on iTerm2 and didn't see a difference when I was trying Kitty. What am
I missing?

~~~
photonios
I notice the difference even when typing. The performance improvement is most
noticeable for me when editing large files in _vim_ or having a lot of _tmux_
panes open. Alacritty and other GPU accelerated terminals perform a lot better
here and things just feel smoother.

There's an older HN thread [1] on the subject with benchmarks and lots of
interesting chatter. It's worth a read IMHO.

[1]
[https://news.ycombinator.com/item?id=14798211](https://news.ycombinator.com/item?id=14798211)

~~~
brennebeck
You might want to try iTerm with gpu acceleration enabled. The only caveat is
you lose some visual features, like transparency, but I found it well worth
it.

------
iconara
On the Example Script page ([https://iterm2.com/python-
api/tutorial/example.html](https://iterm2.com/python-
api/tutorial/example.html)) it says that the script communicates with the
application using websockets ("The underlying implementation uses Google
protobuf and websockets"). This makes me think that it could support other
languages and ways of scripting it in the future.

~~~
bitwize
Wait, web sockets? Why not regular old sockets? Why not restrict it to Unix
domain sockets so that only authorized users can talk to the iTerm instance?

~~~
tdrd
Maybe so folks could build web UIs to interact with a local instance? Can't do
raw TCP/UDP from a web browser.

~~~
bitwize
Then write a bloody wrapper.

Controlling my terminal emulators through a browser is like managing processes
with Doom: something that, while interesting and certainly shouldn't be
precluded, I am unable to think of a use case where I would actually do it.
Making web sockets the scripting interface for a program that in most cases
you do NOT want to actually expose to the web a) makes no sense; b) is a
security incident waiting to happen.

~~~
booi
Manage processes with Doom you say...

~~~
bitwize
Yes, I was specifically referring to this:
[https://www.cs.unm.edu/~dlchao/flake/doom/chi/chi.html](https://www.cs.unm.edu/~dlchao/flake/doom/chi/chi.html)

~~~
tehno
Or Kubecraft :)
[https://www.youtube.com/watch?v=A4qwsSEldHE](https://www.youtube.com/watch?v=A4qwsSEldHE)

------
saagarjha
Ooh, nice! Been waiting for this for a while; now I can finally change my
terminal's theme automatically when the system appearance changes:
[https://gist.github.com/saagarjha/9a99ed4bc68a37bab097cc6ee8...](https://gist.github.com/saagarjha/9a99ed4bc68a37bab097cc6ee83a75ab)

Although, I clicked through the status bar stuff and now I can't figure out
how to get it back :(

~~~
20after4
Under preferences -> appearance you can choose status bar position: bottom (or
top).

Then you can right click on the status bar to get to the editor.

~~~
the_other
I really want to turn off the status bar. I can tell I'm not going to use it,
and now it's just taking up space and confusing my habituated eye as I scan
the screen.

Anyone found an off-button?

~~~
nklas
Go to Preferences > Profiles > Session and at the bottom there's a checkbox
labeled "Status Bar Enabled".

------
20after4
One api feature looks especially cool - that is CustomControlSequenceMonitor
provides a way to implement custom terminal control sequences and extend the
terminal with richer functionality.

------
akerl_
One thing I’d love to port to this:

I switch between a 4K monitor and my built-in. The same font size definitely
doesn’t work between the two of them. I’ve got a script in my .bashrc that
checks the resolution of the current monitor and sets the Profile of the
session using the older control-code based API, flipping between a profile for
each monitor resolution.

With the new API, I can see methods for overriding profile settings on an
individual session, but not a method for changing the profile a session is
using to another saved profile. Does such a method exist?

------
jadiofan
iTerm2 is great, thanks to George Nachman for the hard work. I recently
installed Mojave from scratch, fresh and clean environment. I'm trying to keep
things pretty minimal. I'm giving Terminal (macOS) another shot - so far it's
been great. I've only missed split panes but when I really needed I used tmux.
Other than that I realize I didn't use much of the functionality offered by
iTerm2.

What are the features in iTerm2 that you use the most?

~~~
mlpinit
Setting the background to the solarized dark or light color pallet works
nicely with the same vim pallet setup. I wanted to use this as an example
because I don't believe this worked in Terminal last time I tried it. But
after a quick google search it seems like you can use Terminal for this setup
as well.

Clicking on links in the terminal is a nice feature. If you press cmd + click
it opens your browser or finder. I occasionally enjoy this convenience.

There are probably other conveniences that don't come to mind now.

~~~
kroger
> Clicking on links in the terminal is a nice feature. If you press cmd +
> click it opens your browser or finder. I occasionally enjoy this
> convenience.

On Terminal.app you can cmd + double click to open a link on the browser. (it
doesn't open a path on finder though)

------
chrisweekly
Tangent: like Python in your terminal/shell? See also
[https://xon.sh](https://xon.sh)

------
monkin
Love it and use it from some time! Scriptable status bar is also awesome
feature. :)

------
sirsuki
both iTerm2 and Terminal.app got so slow that I switched to Hyper which
contrary to common sense is blazing fast for me. I’ve also started
experimenting with URXVT via XQuartz but the native feel just isn’t there like
it is for Hyper.

Who knew Electron apps could out perform native ones (even with GPU
acceleration in iTerm2’s case)! I don’t know how or why but in this case it is
so.

~~~
vimslayer
I don't think the main gripe people have with Electron has ever been
performance, V8 is plenty fast after all, it's more about the memory
footprint.

------
frou_dh
Sometimes I've wished that Sublime Text's API used JS so that I didn't have to
know Python just for one program.

It seems a waste having to keep a battalion of imperative OO languages in
one's head just for incidental use.

~~~
pushpop
Learning other languages is not a waste. It actually makes you a better
developer.

~~~
ulucs
Across different paradigms, sure. But many languages are very similar to one
another while only differing a bit in syntax.

If you use a language with a similar paradigm, learning yet another language
in that paradigm will not teach you much, it'll mostly just annoy you with its
subtle differences (I'm talking to you, stored and mutable default variables
of python functions).

~~~
pushpop
Python and JavaScript are at very different ends of the OOP spectrum. JS
encourages a functional approach while Py is more procedural. That small
difference can - and does - have a profound effect of who you structure your
code.

These different designs will teach you different techniques for problem
solving that can be borrowed in different languages when you’re trying to
solve a problem that isn’t easily solved using its classic idiom.

