Hacker News new | ask | show | jobs
by fermienrico 2218 days ago
Is it possible to display images in terminal?

Terminal is simultaneously powerful and painful tool. I know a guy that refuses to use anything but CLI and suffers a lot. But most basic apps can be written it in like those BIOS menus from a 2005 dell computer.

6 comments

You may be unfamiliar with the history of terminals, in which case this explanation is for you.

What you might think of as the terminal is really a terminal emulator. A terminal was a device with a screen and keyboard (early terminals like the Teletype were printers with keyboards, or typewriters). Most could only display text. Up until the late 1970s or so, computers were invariably large and most did not come with their own built-in, memory-mapped display hardware. To access them, you had to use one of these terminals which connected usually via a serial cable.

Because Unix was designed to work with these terminals as the user's means of interaction, terminal emulators which spoke the same protocol as the actual terminals became common. When Unix got graphical displays, terminal emulators were based on them so that old, text-based Unix programs could continue to be used in the graphical environment.

Some graphical protocols for terminals emerged. xterm supports three such protocols: Tektronix 4014, DEC Sixel, and DEC ReGIS. Sixel can be used on xterm to transmit color images. However, Sixel support is usually not compiled in by default.

Perhaps the most sophisticated graphical protocol for terminals to emerge into common use was X itself. Yes, vendors used to sell X terminals that were basically bare-bones computers without any local storage, just a network connection that allowed it to present a windowed display from a remote machine.

It depends on the console/terminal. iTerm has a native ability to do this, the built-in Linux console has some programs like FIM http://www.nongnu.org/fbi-improved/.
iTerm 2 supports imgcat, which shows images inline in the terminal:

https://www.iterm2.com/documentation-images.html

Are you talking about ncurses like interfaces? I have been using tview - https://github.com/rivo/tview/ (based on another library tcell - https://github.com/gdamore/tcell). Very useful.
I am imagining like a gallery app such as Instagram purely in terminal lol never mind the consequences of the user base being primarily sys admins and software engineers. I could imagine browsing a rather weird Instagram clone.
Sort of. Here's a library that does it. https://github.com/sindresorhus/terminal-image