Better MacOS Terminal for Programmers

Photo by Frankie on Unsplash

Better MacOS Terminal for Programmers

Use zsh without installing iTerm2

👋 Introduction

Terminal application is one of the most important, if not, the most important application in MacOS. Although MacOS has several built-in shells, most of the time users use either zsh or bash shells. To check which terminal you are using on Mac, simply open your terminal and type,

echo $SHELL

In this article, we will be looking at how you can configure MacOS’s built-in zsh terminal. To check whether the zsh terminal is on your Mac, type the following command.

cat /etc/shells | grep "zsh"

If you have confirmed that you have zsh shell installed in your Mac you are all set for spicing up the Mac terminal. But if you are not, you have to install zsh terminal. You can install it with brew install zsh But for that, you need to have Homebrew installed on your machine. Homebrew is a package manager tool for MacOS and we need that to make changes to our zsh shell as well.

🍺 Installing Homebrew

To install Homebrew you can simply follow the below given instructions.

  • Run /bin/bash -c "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" to install Homebrew.

  • After the installation, it will provide two commands to run in the terminal as on-screen instructions.

  • 1st command → echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<username>/.zprofile

  • 2nd command → eval "$(/opt/homebrew/bin/brew shellenv)"

  • Type brew in your terminal to confirm you have installed Homebrew correctly.

💻 Install zsh

If you did not have zsh terminal when you ran cat /etc/shells | grep "zsh" , you can install zsh with Homebrew by typing brew install zsh After the installation confirm you have zsh terminal by typing cat /etc/shells | grep "zsh" one more time.

After that, change the default terminal to zsh terminal by typing the below command.

chsh -s /bin/zsh

Restart your terminal to check whether the changes are applied correctly.

🎨 oh-my-zsh

Now let’s make our terminal colorful 🎨 To do that follow the below given instructions.

🤔 auto-suggestions

In addition to making your terminal beautiful, you can also use auto-suggestions with your zsh terminal as well. To use the auto-suggestion capability, simply follow the below-given instructions.

  • Clone git repository and install → git clonehttps://github.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

  • Update .zshrc file → plugins=(zsh-autosuggestions) (If you already have git in the plugins section, plugins=(git zsh-autosuggestions)

  • Source .zshrc file → source ~/.zshrc

There you go! Now you have a beautiful and better terminal to work with your projects from now on! 😊

📚References