Elevate Your Terminal Experience on The Mac 🧘‍♂️
Tags: webdev, tutorial, productivity
Published: 2022-11-05 20:26:51

## The key ingredients to spice up your terminal are Oh My Zsh, Oh My Posh, and Fig

The macOS operating system comes preinstalled with a default Terminal app. As a software engineer, data scientist or if you like geeking around, there's a big chance that you will be spending a lot of time in the terminal running a variety of commands. The terminal with its traditional white text on a black screen is quite bland and uninspiring. It doesn't invite you to stay in that window in order to get more stuff done.


![Unmodified Terminal on Mac with default settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knp6ija6ti9iow43h79v.png)

Upgrading your terminal experience can be done for productivity reasons. You can install a bunch of shortcuts, plugins, and helpers to speed up your everyday processes. Making your terminal more powerful can of course also be done for aesthetic reasons. It will definitely become a more delightful experience every time you use the terminal.

I will outline a five-step process to make your Terminal experience more powerful. Using your terminal will never be the same again after you've seen what's possible. Let's get started!

<hr />
### 1. Replace the Mac Terminal 🕺 
![Screenshot of the Warp terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcvnktxsjnzmsnu0rskx.png)

The default Terminal app for Mac leaves a lot to be desired. Other terminal emulators of competitors provide many extra features that are indispensable for the everyday Terminal user like split pane view, mouseless copy, and a paste history just to name a few.

To get started, I would recommend using [iTerm](https://iterm2.com/) and seeing whether this Terminal emulator fits your needs. Visually, it is the most similar to the built-in Terminal app with added features on top. If you're more adventurous you can try out [Warp](https://www.warp.dev/) or [Hyper](https://hyper.is/). They offer more cutting-edge features like AI-assisted command search and more editor-like command input.

Before installing iTerm, we need to install [Homebrew](https://formulae.brew.sh/) first. Homebrew is a package manager for Mac and allows you to install packages by just executing them in your terminal application. If you haven't installed Homebrew yet, please install this first by running the following in your terminal:
```shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

iTerm can now be installed with brew by running the following command:
```shell
brew install --cask iterm2
```

### 2. Install a Zsh configuration and plugins 📦
Zsh is the default shell that comes pre-installed on all macOS systems since macOS Catalina. Zsh works as an interpreter that translates your terminal commands into instructions for your operating system to run. Zsh on itself isn't very powerful. To improve this, we will install [Oh My Zsh](https://ohmyz.sh/) which is a framework for managing your Zsh configuration. This will allow you to install plugins for your Zsh configuration.

To install Oh My Zsh, simply open up your terminal emulator of choice and run the following command:
```shell
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

After you've installed Oh My Zsh, the output is going to look like this:

![The output of the Terminal after installing Oh My Zsh.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0vic4ju0q6d6b91u719f.png)

Oh My Zsh comes pre-installed with the git plugin. This gives you a bunch of git aliases that you can use from your terminal. A handy few are:
```shell
gst = git status
gaa = git add --all
gl  = git pull
```

For the complete list, please check out the [git plugin page](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git) for Oh My Zsh.

To install other plugins for your Zsh configuration, open the following file in your editor of choice: `~/.zshrc`. The currently installed plugins are denoted by the following line:
```shell
plugins=(git)
```

The exhaustive list of all possible plugins can be found on this Oh My Zsh [plugins page](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins). Do you want to have aliases for 1Password, Spotify, Visual Studio Code, or one for the many engineering scripts that you run? Someone probably created a plugin for that. I would recommend installing the [z plugin](https://github.com/agkozak/zsh-z), which allows you to quickly navigate to a directory you have visited before with minimal keystrokes. Adding extra plugins to your zsh configuration can be done by simply editing the plugin line of the `.zshrc` file like this:
```shell
plugins=(git z brew)
```
After saving your changes, make sure to restart your terminal emulator or run the following command to make use of your latest changes:
```shell
source ~/.zshrc
```

### 3. Install a theming engine 💅
This is probably the most exciting step: theming your terminal emulator! The theming engine that we're going to use is [Oh My Posh](https://ohmyposh.dev/). Oh My Posh has a lot of preconfigured themes and colors for your terminal prompt and makes it very easy to install and configure.

#### 3.1 Oh My Posh
You can install the Oh My Posh theming engine with Homebrew by executing the following command:
```shell
brew install jandedobbeleer/oh-my-posh/oh-my-posh
```
#### 3.2 Fonts
Oh My Posh recommends installing Nerd Fonts. These fonts are patched to include beautiful icons which will be displayed in your terminal prompt. Fonts can be installed with the built-in Oh My Posh command.
```shell
oh-my-posh font install
```
After running this command, you will be prompted to select a specific font. We will choose Meslo, since Oh My Posh recommends this font for its theming engine.

![Font selection during installation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tjr1kzqipgz6590u4v5i.png)

After having installed the Meslo font, you will probably need to configure this font in your terminal application of choice. Setting this up in iTerm settings will look approximately like this:

![Selecting the right font in the iTerm preferences.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nr8alljbaq3b8i4kbwv9.png)

If all is set properly, your terminal should now look like this:

![Oh My Posh installed and font configured correctly in iTerm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ht5r0gnotuovvfazkfe6.png)

#### 3.3 Optional: choose a different theme
You don't have to use the theme that Oh My Posh comes preinstalled with. That's the beauty of it. You can choose any of the predefined themes that are available on [this page](https://ohmyposh.dev/docs/themes). To configure the theme look for the following line in your `.zshrc` file:
```shell
eval "$(oh-my-posh init zsh)"
```
When you've settled on a specific theme like M365Princess, you can change the Oh My Posh command in `.zshrc` file into:
```
eval "$(oh-my-posh init zsh --config $(brew --prefix oh-my-posh)/themes/M365Princess.omp.json)"
```
Don't forget to rerun the command `source ~/.zshrc` to activate your changes. 🚀

### 4. Beautify your ls command 👩‍🎤
When you use your terminal, you list the content of your directory very frequently. The list that is outputted to your screen is very unoriginal and not easy to scan.

![ls command with standard output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5p09y48usa9eizrv57y.png)

Wouldn't it be nice if the output of your ls command could be more distinguishable and easier to scan? [Exa](https://the.exa.website/) to the rescue! Exa is a replacement for the boring ls command and improves it with color, icons, and additional metadata. To install exa, run the following command in your terminal:
```shell
brew install exa
```
Exa doesn't actually replace the ls command in your terminal. To run exa, you will have to give it a bunch of flags to denote what configuration you want your ls command to contain. We can make aliases to replace the standard ls command with exa so that you don't have to type all the flags every time you want to list the content of a directory. We will add 3 aliases for the commonly used ls commands: ls, ll, and la. Open up your .zshrc file and add the following lines:
```shell
alias ls='exa --icons --group-directories-first'
alias ll='exa -l --icons --no-user --group-directories-first  --time-style long-iso'
alias la='exa -la --icons --no-user --group-directories-first  --time-style long-iso'
```
Rerun `source ~/.zshrc` and use the exa command anywhere and be delighted with the output! 🤩

![exa output in a repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pp0epod76tzsp5owq8hp.png)

### 5. Finishing touches: autocomplete magic 🦄
What is a terminal without some autocomplete magic? The intellisense for code completion you get with modern IDEs has become indispensable in a software developer's job. Why can't this intellisense be extended to the terminal? Well, that's possible with [Fig](https://fig.io/)! Fig is an extension that adds some autocomplete greatness to the most commonly used terminal emulators. It works smoothly to autocomplete many commands you can think of, like cdand git . To install Fig run the following command in your terminal:
```shell
brew install fig
```
After installing Fig, open the application from your Application folder and follow the startup process to configure it correctly. When all it's done, you should be left with a terminal emulator that is a feast for your eyes. 🤩 Try using the git add command in a project to see how Fig suggests your unstaged files in the suggestion box.

![Terminal emulator with autocomplete features](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hjrpp3w7cd47qah98gec.png)

### Takeaway
Getting your terminal application to look sharp shouldn't be a difficult and daunting task. Almost all of this can be done quickly by just executing a bunch of commands in your terminal to get the desired results. It's a very small time investment that pays dividends. It may not make you more productive per se, but it will certainly make you feel like a boss using it! Happing coding! 😎




<hr />
If the content was helpful, feel free to support me [here](https://www.buymeacoffee.com/duncanlew):
<a href="https://www.buymeacoffee.com/duncanlew" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>