Oh my zsh

Beautifying your macOS terminal

Henry Chukwu
4 min readMay 26, 2020

The default command line tool that comes with mac is bash and as a software developer you would most likely be working with it a lot: writing shell scripts, installing packages, working with git, etc. so why don’t we make it look better and even more powerful, enter zsh. I would go step by step of how I made my command line to look like this.

Installing zsh

Why zsh? There are lots of articles online with bash and zsh comparisms but as shell user myself, I like the the autocomplete functionality and the ability to customize the look and feel with varioys framework.

You can install zsh by typing this into your command line.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Run zsh in your terminal

$ zsh

Install and setup iterm2

Why iTerm2? Much like zsh, it’s mostly about ease of customization. iTerm2 also has some nice features like split panes, and gets updated more regularly than OSX’s terminal.

download iterm2 and follow the prompts to install, it should be straight forward.

Install Powerline font

For context, Powerline is a status line plugin for vim, and provides statusline and prompts for several other applications. This doc explains why we need special fonts at all, but the tl;dr is: for cool status icons!

Install Powerline-compatible fonts:

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

Themes

You can see a list of zsh themes here. The default theme that comes with zsh is the robbyrussell, we will be using the agnoster theme. To use the agnoster theme open your zshrc file with vim or any other text editor.

$ vim ~/.zshrc

click i to edit vim scroll to the top and look for ZSH_THEME=”robbyrussell” or something similar change it to ZSH_THEME=”agnoster”. Make sure you pay attention to the quotation marks and the spelling.

To close vim click the esc key then

:wq

Click the enter key to leave vim.

Save your changes and update your terminal by typing this in.

$ source ~/.zshrc

Optionally to hide the “user@hostname” info when you’re logged in as yourself on your local machine, open back your zshrc file as above scroll to the bottom and add this:

prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
# prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
fi
}

Reload your terminal again with

$ source ~/.zshrc

Installing neofetch

The last thing is to get the fancy apple symbol whenever you open a new terminal window. We do that by installing neofetch. See installation guide here. First open zshrc file and add neofetch to the end of the file.

# Git clone the repo
$ git clone https://github.com/dylanaraps/neofetch
# Change working directory to neofetch
$ cd neofetch
# Install neofetch using the Makefile
$ make install

If you get a make: *** No rule to make target `install’. Stop. error make sure you are in the right directory when running make install.

Go to Preferences > Profiles > Window and select a background image of your choice for your terminal.

Bonus

Another nice to have feature for your terminal is the ability to easily search for commands you ran earlier, fzf makes this easier.

You need to have homebrew installed first as we will be installing fzf with homebrew

brew install fzf

# To install useful key bindings and fuzzy completion:
$(brew --prefix)/opt/fzf/install

Make sure you add the $ sign for $(brew — prefix). Follow the instructions and click yes to the 3 questions asked. And we are done.

Useful links

I tried to include the links to relevant/useful documentation and Github issues inline, but here are some additional general resources!

This medium article by anh-thu huynh was very useful in writing this post.

Shoutout to Bryan Tong for his tutorial that helped as a starting point for setting up my terminal.

--

--