This blog post is about my findings from my personal transition from Bash to Zsh and describes how I got auto-completion for some small tools such as SSH config files and Git to work correctly and how I gave my new Zsh the look and feel of a modern shell using starship cross-shell prompt.
End of an era
Every macOS user that uses the Terminal on a regular basis might at some point have come across the message that introduced the end of the Bash era when upgrading from macOS Mojave to Catalina.
My first attempt to work around this message was by simply ignoring it. After a while, it began to bother me, and I found another quick but efficient solution by silencing the deprecation message by adding the following command to my ~/.bash_profile file:
This simple move was nothing more than burying my head in the sand, pretending that there is no transition to do. Anyway, it worked pretty well for almost one year. Then over Christmas when deciding to upgrade to macOS Big Sur, I thought that it might be the right time now to definitely say goodbye to my beloved Bash. That was when I removed the command above from the ~/.bash_profile file and opened the pandora’s box with these cryptic looking letters that changed my shell to Zsh:
Can it really be that different?
To make it short: “Yes it can!” At least if you are used to a certain shell behavior and just want your shell to work as you expect it to do. What was going to be meant a thing of minutes ended in a whole day searching for solutions to small but yet impactful problems.
Make it fancy with Starship
On Bash I was an enthusiastic user of Powerline (which was btw also a struggle to get it working the right way, you can find my blog post on how to configure Powerline on Bash here) and I knew that by using oh-my-zsh it would be very easy to install Powerline on Zsh. This would have been an option since I didn’t want to stick with the ugly plain Zsh shell. On the other hand, I wanted something more future proof that really feels like you are working with a modern shell. So, I choose the starship cross-shell prompt since I wanted to try it in action for a pretty long time now.
Installing starship using brew is pretty easy:
To activate it we need to add one more line (two with the comment) to the ~/.zshrc file.
This is basically enough to make it work. But since starship is a modern command line prompt using emoticons (yes, emoticons!), we also need to install a so-called “Nerd”-font which can be downloaded here. I got myself DejaVuSansMono since I found it very pleasant to work with. After downloading and installing the font it needs to be set within the preferences setting of your Terminal application:
For further customizing I took a predefined Terminal color scheme provided by lysyi3m. To do so I cloned the repository, double-clicked on the alucard theme, and set it as default.
The final result does look like this:
When first using Git in Zsh, I soon realized that the autocompletion did somehow not really work as expected. Again, I could have gone the way to use oh-my-zsh with its autocompletion which I personally didn’t find very convenient. So, I stuck with the brew zsh-completions package and the built-in Git auto-completion (for which to work correctly, you need to install a recent version of git using brew):
To make the zsh-completions work you need to add the following commands to your ~/.zshrc file.
When I first installed this, I realized a bug in the Git auto-completion when using it on a git checkout command to check out a remote branch for the first time. By the time of writing anyhow, this bug should have already been fixed, as I could not replicate it.
SSH Config File
Everybody that has used SSH and SSH config files on Bash in Linux knows how convenient and fast a good auto-completion can be. When I migrated to Zsh from Bash on macOS I was really annoyed by how the autocompletion for SSH worked (or not)! Luckily, I found an easy fix to get Tab autocompletion to work as I knew it from Linux. The solution was provided by Gilles ‘SO- stop being evil’ on serverfault.com and helped me quite a lot. Thanks, Gilles! It was nothing more but add this to your ~/.zshrc file.
Visual Studio Code
For me as a software developer, every time I mess around with my Terminal I need to check Visual Studio Code and its built-in Terminal to ensure I didn’t mess it up. Adding the following two lines to my settings.json in Visual Studio Code pretty much brought me the same Zsh experience I was already enjoying in the Terminal Application:
Even though my transition from Bash to Zsh wasn’t a no-brainer, I finally feel satisfied with the result and with the knowledge that I am on the latest shell on macOS. The tweaks described above needed quite some time and I hope I can make your life easier with this blog post. Let me know if you have problems with any of the steps.
About the author
Remo Höppli is Co-Founder and Software Engineer at Earlybyte.
Earlybyte is an IT consultancy firm specialized in developing new digital solutions for companies around the world from digitalization to IoT solutions, close to the client and its business embracing agility.
Follow me on Twitter to get informed on new blog posts.
Remo Höppli - Co-Founder, COO, Software Engineer - Earlybyte GmbH | LinkedIn
I'm a tech enthusiast working in my own Startup-Up company Earlybyte, which I founded with my study peers from ZHAW…
Starship: Cross-Shell Prompt
The minimal, blazing-fast, and infinitely customizable prompt for any shell! Get Started → Works on the most common…
Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher
Iconic font aggregator, collection, & patcher: 3,600+ glyph/icons, 40+ patched fonts: Hack, Source Code Pro, more…
This is a set of color themes for default macOS Terminal.app (initially ported from iTerm2 color schemes, collected by…
Install command: Also known as: zsh-completion Additional completion definitions for zsh…