Skip to content

ZSH on MacOS

| zsh | macos |

Disclaimer: This post doesn’t have verbose “whys” only “hows”!

References

Make ZSH a default shell on MacOS

$ sudo chsh -s /bin/zsh
Changing shell for root.

and

$ chsh -s /bin/zsh
Changing shell for halyph.

Check version

$ zsh --version
zsh 5.8 (x86_64-apple-darwin20.0)

Install Oh My Zsh

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Define agnoster theme

Open .zshrc and add the following line:

ZSH_THEME="agnoster"

Open iTerm2 and you will see this ugly prompt

img1.png

Update iTerm2 font

Install Nerd fonts (see more here)

$ brew tap homebrew/cask-fonts
$ brew install --cask font-hack-nerd-font

Open iTerm2 and update profile settings

img2.png

As you can see ugly ? symbols have been disappeared.

img3.png

Update a prompt

The following changes must be added after source $ZSH/oh-my-zsh.sh line

  • remove use name and laptop name

Add this line to .zshrc

DEFAULT_USER=$USER
  • make PROMPT to occupy two lines and use symbol as the bigging of a prompt

Add this function to .zshrc

prompt_end() {
    echo -n " \e[m\n➜%{%f%}"
}

So, now our prompt should look like this

img4.png

Update VSCode settings

Open VSCode terminal

img5.png

These strange symbols can’t be rendered properly that’s why we should update related setting and adjust terminal’s font:

select and open in VSCode “Preferences: Open User Settings (JSON)” and add the following line to settings.json file:

"terminal.integrated.fontFamily": "Hack Nerd Font"

Now our VSCode termial looks much better

img6.png