---
title: Get instant code examples with LaunchBar
date: 2020-08-07 08:00
slug: howdoi-for-launchbar
categories:
- Code
tags:
- launchbar
- html
- terminal
---

![howdoiheader-rb.png](https://brettterpstra.com/uploads/2020/08/howdoiheader-rb.png)

A long while back I linked a CLI called [`howdoi`](https://github.com/gleitz/howdoi). It's an excellent little tool that searches StackOverflow for code examples for any given query. It recently updated, so I thought I'd try my hand at a LaunchBar action for it.

There's already [an Alfred workflow](https://blog.gleitzman.com/post/48539944559/howdoi-alfred-even-more-instant-answers), if you're looking for that.

This action requires two things: the `howdoi` CLI, and `pygmentize` from the pygments package. Both of these can be installed with [Homebrew](https://brew.sh/):

	brew install howdoi pygments

Once those are installed, just download and double-click the action below to install it. When you run it, it will ask for your query. Assuming it finds a result, it will offer you the option of viewing a syntax-highlighted version of it, copying the raw code to the clipboard, opening the source URL, or saving the query to the `howdoi` cache. I'm not sure about the utility of the latter option, and setting up the cache requires manually creating a `~/.keep` directory. But I figured I'd cover the bases.

![](https://brettterpstra.com/uploads/2020/08/2020-08-06-05.44.44.gif)

Technical details: To do the preview I had it write the code out to a temp file, run `pygmentize` on it with `-g` to guess the lexer and `-f html` to output HTML, then write out a style and the formatted code to another temp file. That temporary HTML file is passed back to LaunchBar with an item action to open QuickLook on it.

Please enjoy.

**[Download HowDoI for LaunchBar v1.0.0](https://brettterpstra.com/downloads/HowDoI.lbaction1.0.0.zip)**

LaunchBar interface for the howdoi CLI

[More info](https://brettterpstra.com/2020/08/07/howdoi-for-launchbar/)

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
