Hacker News new | past | comments | ask | show | jobs | submit login

A couple more that I use often:

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




> Somehow this works even across SSH connections…

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


On imgcat, those extensions to the xterm protocol[0] seem really nice. I've long thought that there needs to be a simple escape sequence for a horizontal divider that doesn't break upon resizing, they should do that next!

Also check out tiv[1] which is an alternative that works with any unicode terminal.

[0]: https://www.iterm2.com/documentation-images.html

[1]:https://github.com/stefanhaustein/TerminalImageViewer


These iterm image extensions are almost there. It is unfortunate that it can only display files, and not image created on the fly (i.e., you dump all the pixel values into the terminal and it shows an image).


The actual extension does support images created on the fly. All that's missing is some commandline tool that'll translate from whichever format it's in to the format iterm expects. For e.g. a PNG image data you could probably get away with a single-line bash script: all it has to do is stick an escape sequence in front of the base64 encoded file contents.


that's great! I hope it will be implemented for xterm and becomes a sort of standard. Sometimes I use "sixels" but they are hopelessly slow and low-resolution.

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.


Mintty/Cygwin has a similar utility[1] for images (I've not tested it over ssh. Should be the same idea though)

[1] https://github.com/mintty/utils/blob/master/showimg


imgcat and image displaying is amazing; I use a matplotlib backend that renders plots inline in the terminal, makes remote working much nicer.

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?


GP is talking about the inline images protocol: https://www.iterm2.com/documentation-images.html


You probably need to download and put it in your path.

https://www.iterm2.com/utilities/imgcat


  $ curl https://www.iterm2.com/utilities/imgcat > /something/on/your/path/imgcat




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: