I’ve used zsh for at least 15 years. Occasionally I’ve toyed with the idea of switching to some of the newer shells such as fish (“Finally, a command line shell for the 90s”) or nushell. I’m stuck in my ways, though, so despite all the cool features and ease of use promised by the other shells, I’ve kept using zsh.
I decided to at least freshen up my shell prompt. In 2012, I added git branch information to my prompt using zsh’s vcs_info. However, I never got around to configuring nice prompts for different git states like rebase.
It was time to fix this. Instead of diving into vcs_info, I decided to use Starship, a cross-shell tool that produces shell prompts for you.
Its default configuration is spammy – for some reason, it insists on displaying the version of the programming language implementation you’re using when you’re in a project directory. For example, if you’re in a directory with PHP files, it shows the version of PHP you have installed. This is information that I almost never need.
However, Starship is easy to customize and you can disable all this stuff. My configuration has now a list of blocks like this:
[php]
disabled = true
What is nice is that Starship’s git support is good and shows useful information
like whether you’re ahead or behind of the upstream branch. I constantly use
git status
(well, my custom alias git st
) to check this, so it
makes sense to put it in the prompt. The downside is that this makes your prompt
slow when entering big repositories.
Another nice touch is that it only shows your hostname when you connect over SSH. This is something I had been meaning to make my prompt do for ages but never got around to it.
My prompt used to look like this:
Now it looks like this:
Yes, I did configure it to be exactly the same. If I want to add some new stuff, now it actually feels doable. And as a pleasant surprise, the new prompt feels as fast as the old one (outside of big git repos)!
If your prompt needs tweaking, I recommend taking a look at Starship – just take your time with the configuration.