enabling powerline status with iterm on macos 14.2.1

Unlike many, I do not move all my macOS settings from machine to machine unless the new machine is a complete replacement for the old machine and the old machine is on its last legs. I’ve done that exactly once, from my 2015 MBP to the 2019 MBP. After that transfer I spent a fair amount of time weeding out items that did not make sense on the new machine as well as items that were a good idea at the time, but time later proved to be a bad choice.

I made the decision after that one full transfer between MBPs to carefully curate all software before installing anything on the new machine. One of the choices I tried on the older MBP was Powerline. It didn’t work, and I almost skipped it entirely on the new MBP, but I decided to install it anyway and try once more to make it work.

I’ve been using Powerline on my Linux systems for some number of years now. I like what it does and how it looks and I try to install it anywhere I have a terminal and a command line prompt. It’s a bit counter-intuitive to want to have a sophisticated command line and terminal on a computer with a graphical user interface, but I keep a terminal environment active because I have decades of CLI experience that has served me admirably (once I was properly trained on how to use it). This post documents how I finally figured it out and what I did to get it to work. And it does work, both on the command line as well as within vi/vim.

Initial Environment

This machine has the following pre-installed:

  • macOS 14.2.1 Sonoma
  • zsh 5.9 (x86_64-apple-darwin23.0)
  • python 3.9.6

This is all you really need to get started. A lot of how-tos (all of them old to very old) insist you install Homebrew (brew), and then via the brew command install zsh. The version of zsh Apple currently uses is the latest stable release, a far cry from the ancient version of bash it used to use.

Installation

Installation needs three main pieces; iTerm2, the Nerd Hack font and the Powerline status software itself.

iTerm2 can be downloaded from here: https://iterm2.com. Once downloaded, unzip the downloaded file and start the binary. Once running, iTerm2 will pick up and use zsh and it will automagically ask you if you want to move iTerm2 into the Application folder of you Mac. Select yes when asked. From that point iTerm2 can be selected via Launchpad, and once launched, you can right click the resultant icon in the Dock and chose to have it stay in the Dock (right click | Options | Keep in Dock).

The font I installed is Hack and can be found here: https://github.com/ryanoasis/nerd-fonts/releases . Download Hack.zip and unzip it, then use Apple’s Font Book utility to install the fonts.

Not all of them will install due to issues with certain fonts, and rather than hassle with trying to resolve those issues I chose to skip them. Skipping the problematic fonts still allowed the fonts I needed to get installed, so no problems there.

Once the fonts are installed, open iTerm2’s Preferences and go to Profiles.

Select Hack NF as the Font, Regular weight. I chose to use a 15 point font size because the size of the 16″ display makes reading 15 point text in iTerm2 very easy. Even at 15 points a lot of text can still be seen in the terminal window.

With the terminal and font set up, install the Python package powerline-status using pip: pip3 install powerline-status.

Once installed execute the following command:

$ pip3 show powerline-statusName: powerline-statusVersion: 2.7Summary: The ultimate statusline/prompt utility.Home-page: https://github.com/powerline/powerlineAuthor: Kim SilkebaekkenAuthor-email: kim.silkebaekken+vim@gmail.comLicense: MITLocation: /Users/wbeebe/Library/Python/3.9/lib/python/site-packagesRequires:Required-by:

The line we’re interested in is the Location at line 9 in the listing. In this example, because I’m not running as root, the package is installed locally in my home directory, which it should be. Every home directory has a $HOME/Library directory. It’s underneath site-packages that you’ll find the site package for powerline. Here’s what we are looking for specifically:

$ ls -AlFh Library/Python/3.9/lib/python/site-packages/powerline/bindingstotal 24-rw-r--r--   1 wbeebe  staff 0B Dec 29 15:32 __init__.pydrwxr-xr-x   3 wbeebe  staff96B Dec 29 17:03 __pycache__/drwxr-xr-x   4 wbeebe  staff   128B Dec 29 15:32 awesome/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 bar/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 bash/-rw-r--r--   1 wbeebe  staff   9.8K Dec 29 15:32 config.pydrwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 fish/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 i3/drwxr-xr-x   6 wbeebe  staff   192B Dec 29 15:32 ipython/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 lemonbar/drwxr-xr-x   4 wbeebe  staff   128B Dec 29 15:32 pdb/drwxr-xr-x   4 wbeebe  staff   128B Dec 29 15:32 qtile/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 rc/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 shell/drwxr-xr-x   3 wbeebe  staff96B Dec 29 15:32 tcsh/drwxr-xr-x  11 wbeebe  staff   352B Dec 29 15:32 tmux/drwxr-xr-x   6 wbeebe  staff   192B Dec 29 17:03 vim/drwxr-xr-x   4 wbeebe  staff   128B Dec 29 15:32 wm/drwxr-xr-x   4 wbeebe  staff   128B Dec 29 15:32 zsh/

The two folders we’re interested in are line 19 (vim) and line 21 (zsh). Since we’re interested in zsh, let’s concentrate on that for the moment.

Underneath the zsh folder is one file we need:

ls -AlFh Library/Python/3.9/lib/python/site-packages/powerline/bindings/zshtotal 32-rw-r--r--  1 wbeebe  staff   5.4K Dec 29 15:32 __init__.py-rw-r--r--  1 wbeebe  staff   6.5K Dec 29 15:32 powerline.zsh

The file powerline.zsh is sourced inside the .zshrc file. But before we add this to our .zshrc file, we need to make one more change for the powerline script to execute. At the same level as the lib (library) folder is a bin (binary) folder. Here’s what that folder holds:

$ ls -AlFh Library/Python/3.9/bintotal 160-rwxr-xr-x  1 wbeebe  staff   263B Dec 29 15:32 pip*-rwxr-xr-x  1 wbeebe  staff   263B Dec 29 15:32 pip3*-rwxr-xr-x  1 wbeebe  staff   263B Dec 29 15:32 pip3.11*-rwxr-xr-x  1 wbeebe  staff   263B Dec 29 15:32 pip3.9*-rwxr-xr-x  1 wbeebe  staff34K Dec 29 15:32 powerline*-rwxr-xr-x  1 wbeebe  staff   624B Dec 29 15:32 powerline-config*-rwxr-xr-x  1 wbeebe  staff13K Dec 29 15:32 powerline-daemon*-rwxr-xr-x  1 wbeebe  staff   385B Dec 29 15:32 powerline-lint*-rwxr-xr-x  1 wbeebe  staff   928B Dec 29 15:32 powerline-render*

You need all the highlighted files for Powerline to work properly. For that, you’ll need to add the path to bin to your full path in .zshrc, for example;

export PATH=$PATH:$HOME/Library/Python/3.9/bin

before you add the following line to .zshrc;

source $HOME/Library/Python/3.9/lib/python/site-packages/powerline/bindings/zsh/powerline.zsh

Once all of that is completed then you should at least get the colorful powerline prompt as seen in the screen capture at the top of this post.

vi/vim Setup

First the bad news. The version of vi/vim supplied by Apple wasn’t built to support Python scripting, and you need that support for this to work. The good news is you can get a version that works, but you’ll have to install Homebrew and then use Homebrew to install that version of Python. First, go to the Brew site ( https://brew.sh ) and follow their directions to install it. Once installed you can install the “proper” vi/vim that will support Python scripting. Please note that you’ll need to add the location where Homebrew installs binaries (/opt/homebrew/bin) to your path in order to execute them. And this should be at the start of path, not the end, otherwise you’ll keep executing Apple’s version instead of the version installed by Homebrew.

For vi/vim, you need to add the following to your .vimrc configuration file;

set rtp+=$HOME/Library/Python/3.9/lib/python/site-packages/powerline/bindings/vimset laststatus=2set t_Co=256

Once that’s in your vi configuration file, the status line should look like the following:

There’s a lot more going on inside my vi config file, but the last three lines enable the bottom status line, and that’s what’s important here.

a new(ish) macbook pro

I’m now the proud owner of another MacBook Pro — the 2021 16.2″ M1 Max MacBook Pro. Specifications include 32 GiB of memory, 1 TiB of SSD, with the M1 Max having the full complement of CPU and GPU cores (10 and 32 respectively) as well as a 16 core neural engine. I could nerd on and on about the M1 Max’s vast technical specifications, but I think I should stop here.

This makes the second Apple Silicon computer I’ve purchased. The first was the 13″ MBP with the basic M1 in December 2021. In both cases each computer was heavily discounted, especially the newest by nearly half its original MSRP. The question is why not get an M2, or possibly an M3 based MBP?

One word: expense. This latest MBP is more than a match for everything I want and need to do, and it’s a computer that I can afford to pay off over time, which is what I have to do. I’ve learned to buy my computers the way I buy camera equipment, which is to wait for it to fall pretty far down the trailing edge before purchasing a heavily discounted copy for myself. I now have a 16″ MBP that is, on average, eight times faster than the Intel i9 2019 MBP that was purchased for me back in early 2020. In spite of all the extra cores in the Intel chip, and the fact it has 64 GiB compared to 32 GiB in this latest machine, I can assure you it runs rings around the 2019 MBP and consumes a fraction of the power doing it. Considering how power and heat are going to play a key part in the unrolling climate disaster, those are critical features to consider.

What was funny to me was powering up the M1 Max MBP for the first time. It still had Monterey (12.5) installed. I had to pull down a 10 GB (!) installation binary to bring the computer up to macOS Sonoma (14.2.1).

macOS Monterey with the download of Sonoma nearly finished

I’d forgotten the skeuomorphism still prevalent in macOS. It was sort of like stepping back in time, well, two years to late 2021.

And then I rebooted and realized that perhaps it the skeuomorphism wasn’t as bad as I thought it was. And then I went to work, moved the dock to the left edge, and trimmed out quite a few apps from the doc. That’s when I realized how much I’d modified it from stock, and how many of the Apple applications I’d forgotten about due to lack of use.

The first application I installed after initial setup was the Vivaldi browser. The second thing I did after that was to change the default Vivaldi search engine from Bing to Duck Duck Go. Now that Microsoft is mixing ChatGPT into Bing and Bing’s query results, I find I neither like nor trust what Bing returns. I then installed iTerm2, setting up that environment, and then installing Brew to pick up the few command-line tools I’d rather not have to live without.

So far, so good. I love the mechanical construction of this MacBook Pro; it’s thicker, as thick as my old 2015 Intel MacBook Pro, and far more robust and thicker than either the Intel i9 MacBook Pro or the little 13″ MacBook Pro. I credit that to the fact that Jony Ive isn’t driving design at Apple anymore, and to that, I say good riddance to the entire style-over-practicality design ethos. This machine has re-introduced MagSafe power connector, as well as an HDMI port and a port for SDHC/SDXC cards directly on the chassis. It also has three USB-C connectors for just about anything else I need. The key here is I don’t need a mass of dongles anymore. I still need one adapter from USB-A to USB-C, but that’s it.

This MacBook might be two years old, but at today’s purchase price it is the best budget solution by far. I contrast the 2019 MBP with this 2021 MBP, and note that the 2019 was three times the cost of this one, and roughly 1/8 the performance level of the 2021 MBP.

Unless some wild event occurs in my life, this will be the last computer of its type I’ll ever purchase. I turned 70 in December and I can’t imagine needing anything more as I approach my 80s, assuming life and circumstances allow me to live that long. So far, I’m amazed and pleased as punch with this MacBook Pro and the Apple Silicon M1 Max.