tips

Ready to get started?

Getting HTML into Fenestro

Easy, you can either pass it a path, or pipe HTML directly into it.

# pipe it in
cat my_file.html | fenestro --name "my file"
# give it a path
fenestro --name "my file" --path path/to/my_file.html

Getting Colorized Terminal output into Fenestro

This is what Fenestro was built for, but you’ll need two utilities to get there.

  1. something to keep the “escape codes” from being stripped away when piping to…
  2. something to convert terminal output escape codes into HTML.

Keeping the colors

When piping information between command line apps, the terminal escape codes are stripped. For example git diff HEAD^ would give you a colorized diff of your code, but when you pipe it to another tool it becomes plain, colorless, text. To maintain those colors you have two options: script and unbuffer. unbuffer will make your life easier, but script is probably already installed on your system.

unbuffer

unbuffer is part of “Expect”, which is an odd collection of TCL scripts for automating various tasks.

You can install it with homebrew:

brew install expect

or using apt-get:

apt-install expect

Once it’s installed you can preface the script you want to invoke with unbuffer, and then pipe that on to oho or aha (see below) to convert it to HTML and load into Fenestro.

unbuffer git --no-pager diff HEAD^

Note: Unbuffer works by convincing your tool that it’s outputting to an interactive buffer. Some tools, like git, expect you to page through long output in interactive mode. You’ll need to disable that on calls that go through unbuffer. With git you just append --no-pager immediately after git For example: git --no-pager diff HEAD^

script

script is probably on your system already on your system, and it works well, but it’s not really intended for this purpose and thus requires additional arguments to turn off its normal behavior.

script -q /dev/null git log --stat -n 4 | oho
      # | |         |                       ^ converts it to html
      # | |         ^ the command to run
      # | ^ we don't want the file it writes
      # ^ don't add status messages

Converting command line output to HTML with oho or aha

Full disclosure, I wrote Oho because I was frustrated with how poor of a job aha did. Then I added support for escape codes aha never even attempted. I’m pretty proud of it.

Oho

Oho takes your colorful terminal output and converts it to HTML. To install it with Homebrew run the following.

brew tap masukomi/homebrew-apps
brew install oho

Once you’ve got it installed, it will convert any terminal output you pipe into it into HTML which it sends to standard out. Pass it the dark flag if your terminal is in dark mode.

unbuffer my_colorful_script | oho --dark | fenestro

Note: some terminal output has colors that don’t look great when extracted. If the script you’re working with is something you’ll be using regularly, you can make a custom CSS to style it, and pass that to oho with the --styling flag.

Aha

Aha is an older unix utility with the same core functionality as oho, but it supports fewer escape codes, and - in my experience - the output tends to be teeny tiny. But, it’s available on all Linux and Unix systems.

You can install it with Homebrew by saying brew install aha or - on Debian systems - run apt-get install aha

I’d recommend running it with the --black option if you run a dark terminal theme.

Putting it all together

Once you’ve got fenestro, unbuffer, and oho installed, you can chain them together like this:

unbuffer git --no-pager diff HEAD^ \
| oho --background="#bababa" \
| fenestro --name "diff"

For things you’ll use often, save yourself typing by making a function in your ~/.bashrc

function dtf{ #diff to fenestro
	unbuffer git --no-pager diff "$@" \
	| oho --dark \
	| fenestro --name "diff"
}
# call that with
# dtf HEAD^
# to get the same effect as the longer command above

Styling Fenestro

Fenestro’s UI is almost entirely generated with HTML, and you can easily override the styling. Check out the README for details.