Heroku CLI meets fzf

While working with tmux and fzf I came across another interesting fzf use case: Use a fuzzy finder to simplify the use of the Heroku CLI.

Imagine you have some apps on Heroku and now and then you want to tail their logs or you want to ssh into one of them. There is one problem with that: You always have to memorize the exact app name in order to run $ heroku logs -t -a awesome-app-staging. Or was it staging-awesome-app? Well, you see the problem with that. Another solution might be to define an alias for every app. However, this doesn’t scale too well…

But what about a fuzzy finder for your Heroku apps in the CLI? 🤖

When I switched to vim, I first heard about fzf and began using it with joy to open my files. I recently started using tmux and there fzf can be a great help as well. This stackoverflow post showed me how to use fzf for switching between tmux windows. I also used this approach to switch between tmux sessions (and shared the solution in the linked stackoverflow post). This eventually lead to the idea of using fzf in combination with the Heroku CLI.

Step by step explanation

The first command should be self explanatory. It gives you a list of all your apps on Heroku. But the format here is important! The command returns two lists. Your own apps and the apps on which you are a collaborator:

After selecting the desired app with fzf, the command finally expands for example to:

$ heroku logs -t -a shrouded-fortress-18816

💪

Hi there, we’re store2be, a Berlin based startup that builds a SaaS enabled marketplace for short term retails space. If you like what we are posting you might wanna check out the store2be tech page or follow our Medium channel.