Awesome zsh prompts can be yours

The adoption of FOSS tools for development has meant that a lot of my time is spent at my trusty terminal prompt. I took some time today to make mine a bit more awesome. Quick Left has killer couches, beanbags, spare rooms, and standing desks. This means I'm mobile a lot, and that my battery level is a concern, so I decided to add this to my prompt:

Battery indicator in prompt

I'm using iTerm2, zsh, and oh-my-zsh, as you all should be. The code is posted here as a gist, but I'll go ahead and show the fun stuff here:

A quick walkthrough: The battery.rb needs to be in a directory that's in your path. I chose usr/local/lib

The encoding is necessary because of the fancy arrow characters. Skip that if you're fine with hyphens. The first two lines backtick to the PowerManagementSETtings tools, and asks for the battery status. This output is typically like

Currently drawing from 'AC Power' -InternalBattery-0 85%; charging; 0:23 remaining

A quick one-liner strips out the percentage value, and a color is chosen based on how full the battery is. This is joined into an output string, and that's what gets displayed in the prompt.

Now, like a Roomba, I'll always know when to go back home and charge up. Awesome!


QuickLeft closeicon

Let's Build Your Project

Phone: 303.242.5536
Quick Left HQ
902 Pearl St.
Boulder, CO 80302
Quick Left San Francisco
665 3rd St.
#150
San Francisco, CA 94107
Quick Left Portland
529 SW 3rd Ave.
2nd Floor
Portland, OR 97204
Quick Left Denver
Galvanize
1062 Delaware St.
Denver, CO 80204