# Setting up zsh with Oh My Zsh, NerdFonts, and StarShip

I thought I would share a quick write up on how I set up the shell on my MacBook Pro. Here's what I'm going to review in this post:

- Set up [Oh my Zsh](https://ohmyz.sh/)
- Install a [NerdFont](https://www.nerdfonts.com/)
- Set up [Starship](https://starship.rs/)

In terms of terminal emulators, I like the good old reliable [iTerm2](https://iterm2.com/). If you don't already have it, you can install it easily with [homebrew](https://brew.sh/) `brew install --cask iterm2`.

# Set up Oh My Zsh 
[Oh my Zsh](https://ohmyz.sh/) has a scripted installer available, so it's really simple to get it installed. Open up iTerm2 and run `sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` 
**Note:** You should definitely check the install script before running it!

![iTerm2 install OhMyZSH](https://cdn.hashnode.com/res/hashnode/image/upload/v1657202586183/sn866akmF.png align="left")

Great we're installed! But, what's this? Some of my old installed apps aren't working (like NVM)? Oh My Zsh overwrites your `~/.zshrc` file, so you will have to edit it to add your missing configuration back in. Your original config was backed up by the installer to `~/.zshrc.pre-oh-my-zsh`. While you're editing your `~/.zshrc`, it's also a good idea to read through all the new options that were added. Once you're done with your edits, restart your terminal and you're off!

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657203520984/L4FC0K2pj.png align="left")

Finally, if you ever want to uninstall Oh My Zsh, just run `uninstall_oh_my_zsh` from your terminal. It will reset your old `~/.zshrc` file, too. 

## Plugins
One of the big reasons I like Oh My Zsh is their [absolutely massive list of plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview). It's easy to enable too many and forget what you even have loaded (and slow down your shell as well!). The ones I use are [aliases](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/aliases), [aws](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/aws), [git](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git), [macos](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos), [npm](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/npm) & [nvm](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/nvm). If I dive into specific areas, like docker/k8s, I'll add additional plugins as needed and then remove them when I'm done. 

# Install a NerdFont

Next up is installing a [NerdFont](https://www.nerdfonts.com/). What is a NerdFont? From the website:

> Nerd Fonts patches developer targeted fonts with a high number of glyphs (icons). Specifically to add a high number of extra glyphs from popular ‘iconic fonts’ such as Font Awesome, Devicons, Octicons, and others.

Essentially, this means you get a font library with a ton of extras that you can use in the console, or anywhere else. So head over to [the download area](https://www.nerdfonts.com/font-downloads) and grab a font that you like. I like [FiraCode](https://www.programmingfonts.org/#firacode). And since I have brew, I install it with `brew tap homebrew/cask-fonts && brew install --cask font-<FONT NAME>-nerd-font`. 

![NerdFont install via brew](https://cdn.hashnode.com/res/hashnode/image/upload/v1657212184359/ln8EGU1kC.png align="left")

And, yes, you may need to figure out the font name... Next time, remember, you can search with `brew search --casks <PART OF FONT NAME>` to take the guesswork out. 

To use the font as your primary in your terminal, open the profiles editor, edit your default profile, and select the NerdFont you downloaded. 

![Open iTerm2 profiles](https://cdn.hashnode.com/res/hashnode/image/upload/v1657212536674/6k7LRcT1Z.png align="left")

![Change font to FiraCode](https://cdn.hashnode.com/res/hashnode/image/upload/v1657212654124/D4XRKoKo4.png align="left")

# Install StarShip

The last thing to do is set up [StarShip](https://starship.rs/), a fast cross-shell prompt written in [rust](https://www.rust-lang.org/). Using homebrew, the install couldn't be simpler. Just `brew install starship`. 

![Brew installing StarShip](https://cdn.hashnode.com/res/hashnode/image/upload/v1657213082074/873Dbl1jW.png align="left")

Once installed, you can `echo 'eval "$(starship init zsh)"' >> ~/.zshrc` to get it to load in your shell every time. Now we have a great prompt, with useful feedback and near infinite customizability. Here is an example of the default when you're in a node project (CDK app in this case). And if you're curious about anything in your prompt, a quick `starship explain` will give you some really useful information. 

![Starship Example](https://cdn.hashnode.com/res/hashnode/image/upload/v1657213482286/asJS3YcW-.png align="left")
[image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657213376040/jfWX1mng4.png align="left")

# Other Customizations

There are a lot of other little extras that I add in, but the basics are above. I'm a fan of the setup used in the [examples of StarShip](https://starship.rs/faq/#what-is-the-configuration-used-in-the-demo-gif). 

- [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) - For some nice autosuggestion display functionality.
- [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) - for those long, complicated command lines with lots of escapes and special characters.
- [iterm2-snazzy](https://github.com/sindresorhus/iterm2-snazzy) - For a nice color scheme in iTerm2. 
