Set up Terminal on Mac 2022
Tags: monterey, iterm2, powerlevel10k, m1
Published: 2022-06-23 02:20:56

## Setting up new Terminal on Mac

- iTerm2
- Homebrew
- Git
- Zsh (Z Shell) and ohmyzsh
- ohmyzsh Themes
- ohmyzsh Plugins
- iTerms2 Color Schemes

### 1. iTerm2
Download at [iterm2.com/downloads](https://iterm2.com/downloads.html)

Set out Status Bar Component Menu
`iTerm2 > Preferences > Profiles > Session > Status bar enabled > Configure Status Bar`

Check out other features at [iterm2.com/features](https://iterm2.com/features.html)


### 2. Homebrew
Download at [brew.sh](https://brew.sh/)
or run this in terminal 
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
It will automatically install Developer tools if not available in your system.
When installation is done, run the two commands from the "==> Next steps:" section found in output of your terminal
`echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/lana/.zprofile`
`eval "$(/opt/homebrew/bin/brew shellenv)"`

### 3. Git
Mac already comes with **git** installed
`git --version`
=> git version 2.30.1 (Apple Git-130)
Get the latest version of git by installing it with Homebrew
```
brew install git
```
`git --version`
=> git version 2.36.1
Double-check your git global configurations
`git config --global --list`
If your _user.email_ and _user.name_ are not set, run the following to set your git global configurations
`git config --global user.email "<youremail>"`
`git config --global user.name "<yourname>"`
Reference: [git-scm.com/download](https://git-scm.com/download/mac)

### 4. zsh and ohmyzsh
#### zsh
Mac already comes with **zsh** installed and set as a default
Check what shell is set as a default
`echo $SHELL`
=> /bin/zsh
If the return is not the above, install zsh with Homebrew
```
brew install zsh
```
`zsh --version`
=> zsh 5.8.1 (x86_64-apple-darwin21.0)
Then [Change the default shell in Terminal on Mac](https://support.apple.com/guide/terminal/change-the-default-shell-trml113/mac) or run the following
`chsh -s $(which zsh)`
#### ohmyzsh
Install **ohmyzsh**, the following will run the install script from [Github ohmyzsh's install.sh](https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh)
```
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```
Reference: [ohmyz.sh](https://ohmyz.sh/)

### 5. ohmyzsh Themes
Pick a theme for your ohmyzsh look, and there are many available at [Github: ohmyzsh Themes wiki page](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes)
[What's the best theme for Oh My Zsh?](https://www.slant.co/topics/7553/~theme-for-oh-my-zsh)
[Reddit: What are some of the best Zsh themes](https://www.reddit.com/r/zsh/comments/qilt6j/what_are_some_of_the_best_zsh_themes/)

The most popular theme is [PowerLevel10k](https://github.com/romkatv/powerlevel10k)

Install [PowerLevel10K](https://github.com/romkatv/powerlevel10k) theme 
```
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
```
`open ~/.zshrc`
find a line **ZSH_THEME="** and update it
`ZSH_THEME="powerlevel10k/powerlevel10k"`

Change PowerLevel10k configurations
`p10k configure`
Change iTerm2 font ([reddit reference](How to change iTerm2 font size? (oh my zsh, powerlevel10k)))
- Quit iTerm2 - `iTerm2 > Quit iTerm2` or press ⌘ Q.
- Start iTerm2.
- Click `iTerm2 > Preferences > Profiles > Text`.
- If you have multiple profiles, on the left, click the one you want to change.
- Adjust Font on the right.

### 6. ohmyzsh Plugins
A list of all **ohmyzsh** plugins is available at [Github ohmyzsh/plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins)
or run `ls ~/.oh-my-zsh/plugins`
To see which plugins are enabled, run 
`echo $plugins`

There are also lots of custom plugins built within [zsh-users community](https://github.com/zsh-users). Install the following custom plugins:

- Clone [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
```
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
```
- Clone [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
```
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```
- Clone [zsh-completions](https://github.com/zsh-users/zsh-completions)
```
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
```
`open ~/.zshrc`
find the line _source "$ZSH/oh-my-zsh.sh"_
add the following before that line
```
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
```
- Activate custom plugins

`open ~/.zshrc`
find a line **plugins=(** and update it
```
plugins=(
git 
zsh-autosuggestions 
zsh-syntax-highlighting
zsh-completions 
)
```
### 7. iTerm Color Schemes
[Github mbadolato/iTerm2-Color-Schemes](https://github.com/mbadolato/iTerm2-Color-Schemes/)
Import color schemes into iTerms 2
```
cd Downloads
wget https://github.com/mbadolato/iTerm2-Color-Schemes/archive/refs/heads/master.zip
unzip master.zip
```
You may need to install **wget** and **unzip** Homebrew formulae
`brew install wget`
`brew install unzip`
Import `.itemcolors` items found at `~/Downloads/iTerm2-Color-Schemes-master/schemes`
`iTerm2 > Preferences > Profile > Colors > Color Presets > Import`

To delete them later, follow this [Bulk remove iTerm2 color schemes](https://gist.github.com/kecebongsoft/11312110) guide.


Update:
How to go one word backwards and forwards using `Option key + Left key` and `Option key + Right key`
https://apple.stackexchange.com/a/293988


---
References:
- https://dev.to/abdfnx/oh-my-zsh-powerlevel10k-cool-terminal-1no0
- https://techviewleo.com/how-to-install-zsh-and-oh-my-zsh-on-macos-big-sur/