15 ms·
lsix: ls for images
- merlincorey 8y agoIt's pretty incredible that this is a bash script that outputs sixel graphics, and it in no way makes use of libsixel[0]. [0] https://github.com/saitoha/libsixel https://github.com/saitoha/libsixel
- theoh 8y agoIt uses various Imagemagick tools (Imagemagick supports sixel). Nobody manipulates binary files/pixel data in bash, do they?
- aasasd 8y ago> nobody That's a strong word you have there.
- floatingatoll 8y agoThey have a point - I can’t find any traces of a shell library implementing image parsing without calling out to a third-party tool written in not-shell. You also have a point - I’m seriously debating if I can write one in an evening solely to say that one now exists. (I lost the debate with myself, sadly.) EDIT: I mean “source language bash”, not “target language bash”, my emscripten friends.
- theoh 8y agoThere are problems with the manipulation of binary data in bash, as discussed here: https://unix.stackexchange.com/questions/278639/how-can-i-work-with-binary-in-bash-to-copy-bytes-verbatim-without-any-conversio https://unix.stackexchange.com/questions/278639/how-can-i-wo... In particular, the value 0 can't be stored in a bash variable, which almost completely rules out the possibility of byte-by-byte processing of general binary data. It's probably possible with absurd hacks. Quite apart from that, error handling in bash is an awkward chore which few scripts get right. It's a very unappealing language for writing anything more than a five-line script. https://www.davidpashley.com/articles/writing-robust-shell-scripts/ https://www.davidpashley.com/articles/writing-robust-shell-s...
- floatingatoll 8y agoIf you read a byte without EOF and have a variable length of 0 afterwards, you read a NUL.
- benj111 8y agoI'd like to think that it was a trap (that floating atoll at least fell in to). This time next year we'll be reading about Bixel (free to use if you build it), the new hotness in binary and pixel editing.
- boomlinde 8y agoPixel data doesn't necessarily imply binary data, though. In the Plain PPM format, pixels are encoded as plain text RGB tuples separated by white space. It's not inconceivable for such a simple format that one could write a simple image processor in a few lines of shell + coreutils.
- kuhhk 8y agoWouldn’t this be more like “cat” than “ls”? List is for listing files, cat is for outputting the files, and this appears to output the image...
- djsumdog 8y agoHmm, it doesn't look like xfce4-terminal supports sixel bitmaps.
- lbj 8y agoHow does the tech work? You have something like a 80x50 display and he's emitting 128x128px on that?
- cyphar 8y agoIt's a VT extension called sixels[1], and requires terminal emulator support. [1]: https://github.com/saitoha/libsixel https://github.com/saitoha/libsixel
- emmanueloga_ 8y agoBy now a lot of ppl have commented on the tech (sixel) but it really annoys me when projects don't explain in simple terms the overall workings in the readme: "lsix is a shell script that uses ImageMagick convert tool to list images on a shell screen on terminals that support the Sixel format" There, was that so hard?!? :-( EDIT: oops, it does mention it, everywhere actually. 1) need to pay more attention but 2) I was just venting because of so many other repos I have to spelunk to have answers for when a few words in the readme would do :-)
- userbinator 8y agoYou can also specify filenames and, of course, use shell wild cards However, some may be slow to render (like PDF), so lsix doesn't show them unless you ask specifically. Regardless of the justification, I don't think creating such extra exception/edge-case behaviours are ever a good idea in a commandline tool like this. The equivalent in regular ls would be something like not showing more than X files "unless you ask specifically" --- which would just create more confusion than anything. As someone who has used the commandline for many years, one property which needs to be present for good usability is consistency. Having a bunch of edge-cases and special behaviours makes a tool hard to use for anything but the most extremely basic of operations.
- pvg 8y agols does not show files starting with .
- binarysaurus 8y agoBut there is a driving purpose behind that, hidden vs non-hidden is binary. With so many media formats I agree that consistency is very important.
- ndnxhs 8y agoThe reason is because it was a lazy hack to hide . and .. from ls and then people started using this behaviour to hide files.
- pvg 8y agoIt's still largely arbitrary. I'm pushing back against the general notion that standard Unix-y command line tools are some shining example of consistency. Most of it is just us confusing familiarity for consistency.
- Wowfunhappy 8y agoThere are some edge cases, but those cases are well-known and simple to understand.
- jopsen 8y agoHow many terminal emulators can handle sixel? (vt340) Does anyone have a list?
- amasad 8y agoAs far as I know it's just xterm on desktop. It's fascinating that we have this standard that allows us to build programming environments like notebooks -- without resorting to layering hacks on hacks to make it work on web -- practically crossplatform yet we don't make use of it. At repl.it we've been toying around with adding sixel support for xterm.js and we have a prototype up and people in our community are already building things on it. Here are a few examples: - gnuplot: https://gnuplot.basicer.repl.run/rob https://gnuplot.basicer.repl.run/rob - gif in terminal (python): https://repl.it/talk/share/SPINNING-GLOBE-GIF-WITH-SIXEL-NEW/9139 https://repl.it/talk/share/SPINNING-GLOBE-GIF-WITH-SIXEL-NEW... - connect 4 game (ruby): https://repl.it/talk/share/Connect-4-20-with-better-graphics-and-more-effects/9338 https://repl.it/talk/share/Connect-4-20-with-better-graphics...
- jopsen 8y agoIt's also facinating that programs that generate text output do so in a format that's well over 40 years old. What if our CLI programs could output HTML or JSON depending on whether they are piped or printed. Both standards are not good for this, but is VT100 really that great?
- Wowfunhappy 8y agoMost terminals use unicode, not ascii, right? Unicode is much younger than 40.
- nwhm 8y agoUnicode isn't an encoding, but most terminals use UTF-8 (check your LANG environment variable), of which ascii is a subset
- amasad 8y ago
- snazz 8y agoSemi-related fun fact: if you have iimage-mode turned on in Emacs (it might be the default on recent versions?), you can just cat images in eshell and have them show up just like this app. Unfortunately it doesn't do sixel graphics in a terminal yet.
- komali2 8y agoDude this is so off topic but I just gotta know what the madness that your hn "about" section is
- _emacsomancer_ 8y agoI needed to advise eshell/cat (as per https://emacs.stackexchange.com/questions/3432/display-images-in-eshell-with-iimage-mode https://emacs.stackexchange.com/questions/3432/display-image... ) before I could get this to work.
- euske 8y agoCooool! Is there any way to get this work with tmux? Currently it seems it's filtering Sixel escape sequences. On a raw xterm it's fine.
- anowlcalledjosh 8y agoProbably not, see https://github.com/tmux/tmux/issues/44 https://github.com/tmux/tmux/issues/44 (tldr: maintainer says no). There's a fork that purports to add support, but it's not been updated for a while: https://github.com/yatli/tmux-sixel https://github.com/yatli/tmux-sixel
- dotancohen 8y agoNote that it is the tmux maintainer, not the libsixel maintainer, who is saying no. He won't even add support if someone else provides the patch, unless the patch is small. Why? Because: > "I am not interested in graphics in the terminal and there are few practical uses for them anyway." Really? I wonder how the *nix environment would look like today if the tools (gnu, et al) only worked with the workflows that their original creators envisioned. In fact, just recently I had to SSH into a remote server and find a particular image. The filenames are random strings, and the timestamps were useless as the files were recently copied from an archive drive without the `-a` flag. Having image support in the terminal would have saved me enough time to pick up my little one from kindergarten myself instead of having to send someone else to pick him up for me.
- isomorphic 8y agoAside: Although iTerm2 (on macOS) doesn't appear to work with this, iTerm2 actually supports full-color inline images, and has an "imgls" script which does something similar. (There's also "imgcat".) https://www.iterm2.com/documentation-images.html https://www.iterm2.com/documentation-images.html
- cyphar 8y agoThis is because iTerm2 doesn't support sixels (which is part of a VT standard I believe), and instead has its own custom version of the same thing.
- xzfc 8y agoNot quite the same. iTerm provides escape sequence to inline base64-encoded images in a common format (e.g. PNG)[1] whereas Sixel is an it's own image format. I find iTerm's approach is more simple yet more powerful: better compression, thus faster; no dithering, thus better image quality; it's even have GIF support. Sixel is an 30 year protocol designed for matrix printers, i'm not sure why we should stick to it. I think terminal emulators should adopt iTerm escape sequence rather than Sixel. Aside of iTerm, image inlining is supported in Terminology[2]. Not sure about compatability with iTerm however. [1]: https://www.iterm2.com/documentation-images.html https://www.iterm2.com/documentation-images.html [2]: https://www.enlightenment.org/about-terminology.md https://www.enlightenment.org/about-terminology.md
- osiutino 8y agoI used the imgcat trick in my shell client project (https://github.com/u59u75u65/hkgbox-rs https://github.com/u59u75u65/hkgbox-rs). I was looking for a cross platform solution, but by the time I worked on it I didn't know Sixels. One of the things that is cool about imgcat is that it handles GIF animation by default.
- fouc 8y ago>iTerm2 extends the xterm protocol with a set of proprietary escape sequences. I wonder if any other terminal uses the same escape sequences. If not, why not?
- EGreg 8y agoDoes this work in MacOS terminal and SSH?
- Iwan-Zotow 8y agosomething similar exists for iTerm2
- pmarreck 8y agohttps://www.macterm.net/ https://www.macterm.net/ seems to support sixels EDIT: And despite the option in there being on, I can't seem to get it to output graphics instead of binary garbage when I use the "lsix" bash script.
- makecheck 8y agoI will try to help if I can. It does work for me. The script seems to depend on ImageMagick "convert" for most of its work; when I run "convert -version" I see "ImageMagick 7.0.6-0 Q16 x86_64 2017-06-12", is this newer than the version you are using?
- pmarreck 8y agoI got it to work either by picking a different terminal type or restarting the app after enabling the option!
- tedunangst 8y agoI would be wary about feeding untrusted inputs to imagemagick. Running this in your downloads directory could be surprising.
- jstewartmobile 8y ago"untrusted inputs to imagemagick", stickied to the top, with a big yellow exclamation mark beside it
- walrus01 8y agoAlso fun with text, you can use aalib as an output renderer with VLC to watch any video as ASCII art. For example 'the matrix' I know Kung Fu scene. https://en.wikipedia.org/wiki/AAlib https://en.wikipedia.org/wiki/AAlib
- fake-name 8y agoWorks in cygwin/MiniTTY. Awesome! OTOH, when using screen, it completely poops itself. Sadface. Also, wow, it's slow.
- icebraining 8y agoSomeone made a fork of screen with sixel support: https://bitbucket.org/arakiken/screen/branch/sixel https://bitbucket.org/arakiken/screen/branch/sixel (caveat usor!)
- jandrese 8y agoDespite being old as the hills and seemingly unchanged over the years ImageMagick still manages to be slow. It is a mystery how the developers managed this feat. It's a shame that netpbm seems to be mostly dead, it always worked much better for the kind of tasks that most people use ImageMagick for, at least for me.
- amyjess 8y agoWell, I learned three things today: - Sixels exist - Konsole doesn't support them. - I don't have xterm installed. After installing xterm and trying this out, I'm pretty impressed. Though not impressed enough to stop using Konsole.
- kristopolous 8y agoSize would be a nice option
- makecheck 8y agoI verified that "lsix" works with MacTerm (my project), which implements Sixels and incidentally also implements the iTerm2 sequences used by "imgls". Rendered areas can be selected and saved or dragged as whole pictures, which may be useful for remote images.
- utopcell 8y agoBeautiful! (-:
- koshak 8y agoEvery time I see the word beginning from sumbol "l" I can’t tell whether it is "l" or "I" The only font designers who care about clear distinction of symbols are those who create fonts for coders Simple clarity test: Il10O All 5 chars should have clear distinction. Otherwise the font is shit.
- y4mi 8y agooften, you can clearly distinguish them from each other... but still don't know which is which. though i admit, that its become pretty normal for the I to be smaller than the l and the O to be rounder than the 0. I'd prefer that to be even clearer. I.e. a point in the Zero or rounding the ends of the small L
- quickthrower2 8y agoNice, but by the time you want to do this, why not use a GUI file explorer with image thumbnails
- ubercow13 8y agoFaster over SSH maybe? Where the thumbnail can be generated remotely
- quickthrower2 8y agoNice point I hadn’t thought of that scenario. Thanks.
- wazoox 8y agoDoesn't seem to work neither on Ubuntu nor Slackware Linux for me... It only outputs some error messages about "missing delegates for this format" and other errors (ImageMagick 6.9.7.4 and bash 4.4.18 in one case, and IM 6.9.4 and bash 4.3.48 in the other; same kind of errors).