weather: cloudy, 6°C mood: nostalgic for times long gone ~/.plan: getting a Minitel terminal to hack on --- I generally manage all software on my mac - both CLI and graphical - using Homebrew[1]. This has a number of benefits: * I don't have to use Apple's horrid Apple ID and App Store * I have access to way more software than what Apple's App Store allows * Updating everything is seamless and can be done from a terminal That said, sometimes I need a package that either doesn't exist in the brew package tree, or it does exist but is not configured in the way that I want. This recently happened to me, as I wanted to try out the w3m[2] text-based web browser with sixel[3] support. ## Sixel magic A few steps are required to get this working. First, we need to install libsixel[4] to give us the img2sixel binary, which is responsible for converting images to sixels. Then, we need to compile w3m with image support. Finally, we need a terminal emulator that supports sixels. My terminal of choice (iTerm2) does and many others[5] support it as well. Unfortunately, there is no tmux support yet but if you're brave, there is a tmux fork[6] with sixel support. Libsixel is available as a homebrew package so that's a quick install but the brew-provided w3m package doesn't come with sixel image support. In those cases, where something in brew isn't as you prefer, you can generally do one of two things: * Use "brew edit " to edit the brew Formula and then reinstall the modified package * Compile from source while linking against the brew build environment Both come with pros and cons. The brew edit route keeps everything as a brew package but leaves you with a local change in the package tree. Then, every time you run brew update and there is an update for the modified package, brew will ask if you want to keep the changes or overwrite them. There are ways around this (one of them is to fork the package tree and put your changes in a separate branch) but none of them are really user-friendly. Things like this are a lot easier with Gentoo's portage[7], for example. That is why I chose the latter and prefer to compile things from source. It gives me a bit more flexibility, while still making use of the brew-managed libraries and build environment. To do this, however, we do need to jump through a few hoops. ## Installation I first pulled w3m from source: $ git clone https://github.com/tats/w3m $ cd w3m Then, we need to import the brew environment into our existing shell. You could do this manually but luckily, there is brew sh, which will do all of this (environment variables, compiler flags, etc) for you. Once we're in the brew environment, we need to compile against brew, potentially using brew libs where needed. In my case, I set the prefix and added support for ssl using the brew-provided openssl library. Again, brew has us covered with brew --prefix. From there on, it's just a simple make and make install to finish things: $ brew sh $ ./configure --prefix=$(brew --prefix) --enable-image \ --with-ssl=$(brew --prefix openssl@1.1) $ make $ make install ## Usage Finally to test everything, just run w3m -sixel. Additional parameters can optionally be passed along with the W3M_IMG2SIXEL env var: $ W3M_IMG2SIXEL="$(brew --prefix)/bin/img2sixel -d atkinson" \ w3m -sixel -o display_image=1 \ "https://cyberscoop.com/boston-l0pht-hackers-tech-scene/" So we get those sweet, sweet images in our terminal[8]! --- [1] https://brew.sh [2] https://github.com/tats/w3m [3] https://github.com/tats/w3m/blob/master/doc/README.sixel [4] https://github.com/saitoha/libsixel [5] https://www.arewesixelyet.com [6] https://github.com/csdvrx/sixel-tmux [7] https://wiki.gentoo.org/wiki/Portage [8] gopher://ghostze.ro/I/img/w3m-sixel.jpg