The ultimate Mac M1 Terminal (iTerm2 + Oh My Zsh + zsh-syntax-highlighting )

Download and install iTerms2 from here

iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.14 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.

Install Oh My Zsh

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

After:

Install zsh-autosuggestions

Fish-like fast/unobtrusive autosuggestions for zsh. It suggests commands as you type based on history and completions.

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc)

nano ~/.zshrc

plugins=(git zsh-autosuggestions)

Start a new terminal session.

Install zsh-syntax-highlighting using Oh-my-zsh (Preferred)

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.

Clone this repository in oh-my-zsh’s plugins directory:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Activate the plugin in ~/.zshrc:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

Start a new terminal session.

Second option: Install zsh-syntax-highlighting using Homebrew on Mac M1

The new Macs with M1 chip use the arm64 CPU architecture. Rosetta 2 is an emulator built into macOS Big Sur that allows ARM Macs to run the old intel applications. To install Homebrew on Mac M1, run the installation command with the arch -x86_64 prefix:

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

The command will run the default homebrew installer and set up it in the /usr/local directory. So whenever you need to do something with brew again, you just need to put before arch -x86_64:

arch -x86_64 brew install zsh-syntax-highlighting