# Installing ZSH, Oh-my-Zsh on Ubuntu, MacOS

Oh-My-Zsh is a framework for Zsh, the Z shell.

## 1. Install and set up zsh as default <a href="#heading-1-install-and-set-up-zsh-as-default" id="heading-1-install-and-set-up-zsh-as-default"></a>

The recommended terminal for MacOs is iTerm2. You can download [here](https://iterm2.com/downloads.html)

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FMfaNXbgmq5lBRlwgUo9r%2Fimage.png?alt=media&#x26;token=93ab243f-5e49-4c3d-85dd-c9c88c4d9a64" alt=""><figcaption></figcaption></figure>

With Iterm2, your default shell is zsh.&#x20;

### 2. Install oh-my-zsh and Powerline fonts <a href="#heading-2-install-oh-my-zsh-and-powerline-fonts" id="heading-2-install-oh-my-zsh-and-powerline-fonts"></a>

To continue installing software on MacOS **Homebrew** need to be installed. Homebrew is a package manager that allows you to easily install, manage, and update software on macOS.&#x20;

To get started with Homebrew, you can install it using the following command in the terminal:

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

Once installed, you can use commands like:

* `brew install` to install a package.
* `brew update` to update Homebrew and its package database.
* `brew upgrade` to upgrade all installed packages.
* `brew uninstall` to remove a package.

Homebrew is widely used for managing command-line tools and applications on macOS.

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FBtIaepL1dd3fQnFqyQQ0%2Fimage.png?alt=media&#x26;token=505f890c-3394-4ea2-b7a6-f62f03fa4965" alt=""><figcaption><p>Homebrew installation</p></figcaption></figure>

**Installing Powerline fonts**

Copy and paste these commands to your terminal.&#x20;

```bash
brew install --cask font-source-code-pro-for-powerline
```

### 3. Change to a brighter colors <a href="#heading-3-install-the-most-useful-plugins-for-zsh" id="heading-3-install-the-most-useful-plugins-for-zsh"></a>

You can use my colors profile.  You can get it [HERE](https://drive.google.com/drive/u/0/folders/1lNo5rwPPVQpEIRSVBbngYS9ZdvxCxPs-)

After that, go to **Iterm2 Settings** -> **Gerneral** -> **Settings** and **Import All Settings and Data...**

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FdIcPvlNiZzRHjNRNVoHG%2Fimage.png?alt=media&#x26;token=8051a7f4-911a-4301-8d1a-0fff412b4181" alt=""><figcaption><p>Import Settings</p></figcaption></figure>

If you want to choose your color, select the Profiles tab then edit the color in **ANSI colors** by your favorite. (Set ANSI blue color to a brighter color. )

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2F62QyqaJkgG23lzB3bumy%2Fimage.png?alt=media&#x26;token=d7a10e8f-070a-4738-86ce-3e65d6b5ffa2" alt=""><figcaption><p>Select Colors Presets ( Solarized Dark is recommended)</p></figcaption></figure>

* Set ANSI blue color to a brighter color. If you want to choose your color, select the Profiles tab then edit the color in **ANSI colors** by your favorite. Three main colors you can see simultaneously with the change in the terminal are:

  * Text color
  * Cursor color
  * Command color

  <figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FuCIXAxiLRWHmpAfZ43tS%2FScreenshot%202024-06-05%20at%208.17.09%E2%80%AFAM.png?alt=media&#x26;token=408c29f2-e6fb-4788-8460-70d8dff9ea15" alt=""><figcaption><p>My Color Profile</p></figcaption></figure>

### 4. Using a fancy theme for zsh <a href="#heading-4-using-a-fancy-theme-for-zsh" id="heading-4-using-a-fancy-theme-for-zsh"></a>

Open .zshrc file using nano editor

```bash
nano ~/.zshrc
```

Find the line *ZSH\_THEME="robbyrussell"* and replace **robbyrussell** with the **agnoster** theme in the .zshrc File. After that, press CTRL + X and Enter to save.

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FSs1P6FiIv5xQbsgIGZjJ%2Fimage.png?alt=media&#x26;token=b1f807e9-2b34-44ca-b145-0868d17e30a5" alt=""><figcaption></figcaption></figure>

### 3. Install the most useful plugins for zsh <a href="#heading-3-install-the-most-useful-plugins-for-zsh" id="heading-3-install-the-most-useful-plugins-for-zsh"></a>

The most useful plugins for zsh are syntax highlighting and autosuggestions.

```bash
brew install zsh-syntax-highlighting zsh-autosuggestions
```

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FzrMGCGh6NEdA4sBblbqY%2Fimage.png?alt=media&#x26;token=a3b37b34-f1a0-4dce-b65d-4f378bac642e" alt=""><figcaption></figcaption></figure>

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

```bash
nano ~/.zshrc
```

Find the line of enable plugins and add *zsh-autosuggestions* and *zsh-syntax-highlighting*

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1669906107498/ltRpFWeoJ.png?auto=compress,format\&format=webp)

**Ctrl+X** to close nano editor with key **Y** to save changes. After all, reload zsh to enable plugins with command

```bash
source ~/.zshrc
```

If for some reasons, plugins could not install, do it manually by downloading them and putting them in the correct path.

COPY

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

<figure><img src="https://2690143064-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlDmbGgN2FnByRhYou8DB%2Fuploads%2FNTlXlf4xHS1JCtPU47Y1%2Fimage.png?alt=media&#x26;token=83cd134b-7efe-4b4f-9f23-8d33e519a13e" alt=""><figcaption></figcaption></figure>

* Install Powerline fonts
* Change the default font of the terminal to Powerline font
* Set ANSI blue color to a brighter color

{% hint style="info" %}
✅If the username and host always display at the beginning of the prompt make you feel annoyed, you can remove it permanently by following these steps:

COPY

```bash
nano ~/.oh-my-zsh/themes/agnoster.zsh-theme
```

Go to the bottom of file and comment out the line "prompt\_context"

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1669912951825/3Br60d6Mx.png?auto=compress,format&#x26;format=webp" alt="" data-size="original">

Reload the shell and enjoy!

```bash
source ~/.zshrc
```

{% endhint %}

Resources:

* <https://gist.github.com/stramel/658d702f3af8a86a6fe8b588720e0e23>
