I’ve found myself using the command line a lot more as part of my day-to-day development process and stumbled across a few neat tools that make life in the terminal a lot more pleasant, which I wanted to share.
- Use iTerm as a terminal replacement
- Install Oh My Zsh and the Zsh Syntax Highlighting package
- Install Pure Zsh prompt
- Configure iTerm colours and Status Bar
The end results looks like this — note the colourisation in the console, the Git status (showing branch name and remote status) and the status bar components (bottom) showing resource usage (Battery, CPU, RAM and Network)
The above is my preference, but it’s all super configurable, and the process to get this setup is pretty simple. You can dive right into the links above, or read on for the details.
The Console app on macOS is ok, but once you dig into what iTerm is capable of, there’s no going back.
If you don’t believe me, this is from the iTerm website :)
iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.12 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.
Download and install instructions available here http://iterm.com
There are other alternatives as well (eg, Hyper), and a lot of the packages and utils mentioned here have ports for all the popular consoles, so don’t despair if iTerm isn’t for you.
Install Oh My Zsh
With iTerm installed, you have a working Zsh, but to fully exploit the command line, you need to get Oh My Zsh. Install instructions are here https://github.com/ohmyzsh/ohmyzsh
Again, from the website —
A delightful community-driven (with 1500+ contributors) framework for managing your zsh configuration. Includes 200+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, php, python, etc), over 140 themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
Why would you not want it! Just don’t go crazy on the plugins, they can definitely impact performance.
Install Zsh Syntax Highlighting
One plugin you probably do want to install is Zsh Syntax Highlighting, which you can get from https://github.com/zsh-users/zsh-syntax-highlighting
From the website —
This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.
This package provides instant syntax highlighting in the console. As an example, you get instant feedback on whether the command you are typing is valid —
One feature of Oh My Zsh is the theme support. There are a lot. Like A LOT. Many of them include some form of support for Git status. Personally, I didn’t find one I liked, so I switched to the Pure terminal prompt. It’s fast, light weight and (I think) very easy on the eyes.
The tl;dr —
- Install the Pure prompt with
npm install — global pure-prompt
- Open your
ZSH_THEME="".This is important to allow the Pure prompt to work its magic.
- Still in your .
zshrc, but somewhere after the
source $ZSH/oh-my-zsh.shline, include
autoload -U promptinit; promptinit
Pure prompt should be good to go as the default now.
Configure iTerm Colours and Fonts
If you’ve been following along and open an iTerm window, you’ll see that the colours aren’t great. To get the most out of the Pure prompt, get the Snazzy iTerm colours from https://github.com/sindresorhus/iterm2-snazzy and use the Colour Presets setting to load them.
Next, change the font to Menlo.
If you open a terminal, things should be looking a lot nicer. But we’re not done! Now for the status bar.
Configure iTerm Status Bar
Before configuring the iTerm Status Bar components, make sure it’s enabled —
Now configure the components you would like to see in the iTerm Status Bar. You can customise the colour (or choose Rainbow!) for each component.
That’s it! iTerm, Oh My Zsh and Pure all have a host of configuration options and plugins to try, so I’d encourage you to go look at their websites for more info and make that console experience your own!