by saagarjha · 6y ago · 0 comments
* imgcat: you can view images without leaving your terminal. Somehow this works even across SSH connections…
* Python scripting API: basically AppleScript for iTerm except it lets you touch pretty much everything and it's not soul-crushing to write. I have mine switch between themes based on the system appearance (which changes based on the time of day).
The source code[1] is quite simple to read (as long as you know Bash) but basically imgcat prints a special OSC[2] sequence (some bytes that tell the terminal to do something special) to stdout followed by the image data which iTerm then handles specially because of the OSC sequence, as far as SSH knows they're just some bytes that it needs to send (no different than running normal cat on a text file). You can kind of think of this as the opposite of what bracketed paste[3] does, in bracketed paste the terminal tells the program to treat some data specially but with imgcat the program tells the terminal to treat some data specially.
[1]: https://iterm2.com/utilities/imgcat
[2]: https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequen...
[3]: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-B...
Also check out tiv[1] which is an alternative that works with any unicode terminal.
Not much a fan of the base64 encoding here. I'd prefer if it was the pixel binary buffer data that you output directly, pinching a hole in the terminal protocol. The fact taht it is binary does not pose problems if the escape sequence contains the size of the image.
Along with imgcat there’s it2dl. Downloads a file from the remote system browser-style. It’s much more convenient than scp, especially when several sessions deep.
-bash: imgcat: command not found
am I missing something? $ curl https://www.iterm2.com/utilities/imgcat > /something/on/your/path/imgcat