Beautify your native macOS Terminal with Oh-My-ZSH and PowerLevel10K
If you are a fan of command line interface and looking for a new look for your native macOS terminal, this guid is for you. I have successfully configure it on various version of macOS includes Sierra, Mojave, and Catalina. It should also works well with prior version of macOS.
In this guide, I will walk you through to turn your boring terminal on macOS into a more attractive and powerful one. See the figure below
First, install oh-my-zsh
Before we start, please note that ZSH is the default shell on macOS Catalina, so if you are on earlier version of the macOS, please change your terminal shell to zsh. You can do so by executing the following command on your macOS terminal.
$ chsh -s $(which zsh)
Note: you don’t need to install oh-my-zsh on Catalina MacOS and as it is pre-installed. But you are recommended to install it to get the latest update with configuration you need for the later part
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
If you couldn’t run the above script on your terminal for some reasons, try the following options:
# This script should be run
# via curl:$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or via wget:$ sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"# or via fetch:# sh -c "$(fetch -o – https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Then source it
$ source ~/.zshrc
Then, I will walk you through install and configure PowerLevel10k
On the macOS terminal, change your current directory to /Users/your_username by
$ cd ~
Then create a special directory called .powerlevel10k (note that the directory name is prefixed by a dot) by
$ mkdir .powerlevel10k
You can also create a directory without the prefix do and it will work without issue but you will see it whenever you use “ls” command to list the above directory contents.
If you want to see the directory created above, you can do so by (note that you need to list all directory with “-a” option
$ ls -la
$ ls -la ~/
Then clone PowerLevel10K to the directory created above by
$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/.powerlevel10k
And execute the following line
$ echo "source ~/.powerlevel10k/powerlevel10k.zsh-theme" >>! ~/.zshrc
Powerlevel 10k requires a styling font to correctly show icon characters, so you need to download and install one of the fonts in https://github.com/romkatv/powerlevel10k but I would recommend you to install Meslo LGS Regular font which I find it work perfectly well on my Macbook.
After the installation of the above font is complete, set it as your default terminal font by going to
Terminal => Preferences… => Profile => Under Text tap, click on Change button at the font section and set to Meslo Regular with your preferred font size. See the figure below for your reference.
You can now can configure your terminal interface as you wish by relaunching your mac terminal or execute the following command
$ p10k configure
After executing the above command, just follow the wizard. It is quite straightforward. You should see the icon characters shown correctly as follows
Type y for yes to move to the next step if you see the diamond character as shown above.
After confirming the above step, you will be taken to the initial stage of configuring your mac terminal interface as below. Choose your preferred style by typing a number represents each option as shown on the screen.
Just follow the wizard you can turn your terminal look into a more attractive one. See one of the sample below
If you don’t like it, you can restart by choosing r option or y to confirm your choice. Then it will take you to the final step and you should be able to choose option 3; otherwise type 1 to finalise.
Now it is time to configure Oh-my-ZSH
Oh-my-zsh allows you to extend your CLI functionality through its plugins. I will show you a few of them and do your homework one the rest :).
Here is the list of oh-my-zsh plugins
You can now install oh-my-zsh plugins. The first plugin I want to show you is zsh-autosuggestions for command completion.
To install your plugin, you need to navigate to the oh-my-zsh plugin directory by
$ cd ~/.oh-my-zsh/custom/plugins
Then install the plugin by cloning it from a git repository
$ git clone https://github.com/zsh-users/zsh-autosuggestions
and update your .zshrc file by appending the zsh-autosuggestions to your plugins list as shown in the figure below
and reload your macOS terminal by relaunching it or run the command below
$ source ~/.zshrc
Press tab if you like the suggestion
Another plugin I want to show you is zsh-syntax-highlighting which not only highlight your syntax but also verify its correctness
To install the plugin, as above, navigate to the oh-my-zsh plugin directory then clone the plugin onto it as follow
The same as above, you need to append it to the plugin list in .zshrc file and you should have the list as shown in the figure below
and definitely you need to reload your shell again (see previous step for instruction). You can now see your terminal can highlight and verify your syntax as you type