Journey to Engineering

Search IconIcon to open search

My Ubuntu/MacOS Terminal Setup

Last updated Oct 3, 2022

The default Ubuntu Terminal app is not that great (and probably the macOS’ one is even worse). But it does take minimal effort to set up a few basic tools that will help Terminal productivity a lot.

My setup is based on the Zsh shell, with the Oh-My-Zsh framework and the powerlevel10k theme. In addition, I use the following plugins:

In this guide, you will learn how to set up a similar configuration.

# Prerequisites

# Zsh Setup

You can skip this step if you are on macOS 10.15 (Catalina) or above: Zsh is already the default shell.

Zsh is a shell that is built on top of Bash, the default Ubuntu shell. For most purposes, what you can do in Bash you can do also in Zsh.

Use the following commands to install Zsh.

1
2
3
4
5
6
7
8
# List all the available shells
cat /etc/shells

# Install zsh
sudo apt install zsh

# Check the zsh path
which zsh

Once Zsh is installed, you need to set it as the default shell. While there is a command to change the login shell, gnome-terminal will still default to use Bash1.

You can force it to use the new shell following these steps:

  1. Open a new Terminal window (ctrl + alt + T)
  2. Click on Terminal > Preferences on the top left side of the screen.
  3. Under Profiles, select default to modify the default profile.
  4. Navigate to the Command tab
  5. Check both boxes
    • Run command as a login shell
    • Run a custom command instead of the login shell
  6. Write zsh in the Custom command text box
  7. Set the When command exits dropdown menu to Exit the terminal
  8. Close the preferences and the Terminal window.

Next time you will open the tab, Zsh will be used instead of Bash. From now on, shell configurations (aliases, etc.) should be added to the .zshrc file.

Screenshot of the Terminal Settings pane

Screenshot of the Terminal Settings pane

# Setup Oh-My-Zsh

Oh-My-Zsh is an open-source framework to manage the Zsh configuration. Briefly, it makes it easier to customize the shell configuration and install plugins.

Installation is quick: you need to paste a command into your Terminal. Reference the documentation to know which command you must use.

The .zshrc file provided by Oh-My-Zsh is very well commented and can offer details in case you get stuck during some customization.

# Install powerlevel10k Theme

powerlevel10k is a theme for the Zsh shell: good customization, with tons of features that will help you when using git or other tools. It is also very fast.

Also in this case, installation is really quick, you only need to clone a git repo. Check the documentation to know the exact command for Oh-My-Zsh users.

Once you cloned the repo, do the following:

  1. Open a new Terminal window.
  2. Open the .zshrc file (for example with nano .zshrc).
  3. Set the ZSH_THEME variable to "powerlevel10k/powerlevel10k".
  4. Close the editor (ctrl + X and Y in case of nano).

Once you reopen the Terminal app, the theme configuration will take place. Follow the instructions and choose the settings you prefer.

To change your settings later on, you can trigger the configuration process by typing p10k configure.

# Installing Plugins

There is a plethora of plugins for the Zsh shell. I like to keep my list small, but you can find the STANDARD plugin list on GitHub.

The STANDARD plugins are the ones already installed with the Oh-My-Zsh framework. To enable them:

  1. Open the .zshrc file.
  2. Search for the plugins variable (near the end of the file).
  3. Add the list of plugins you want to use between parentheses, separated by a single space. In my case, I have
1
plugins=(git ubuntu)

There are also some other plugins, developed and supported by the community. To use them

  1. Clone the plugin GitHub repo into .oh-my-zsh/plugins/.
  2. Add the repo name to the plugins variable like with standard plugins.

I like to use the following plugins:

In the end, my plugins variable is

1
plugins=(git ubuntu zsh-autosuggestions zsh-completions zsh-syntax-highlighting)

# Conclusion

If you followed the complete tutorial, you should have a very fast and visually pleasing Terminal, with auto-completion and syntax highlight. You can go on to customize your setup as you prefer.

Enjoy!