Beautify Mac Terminal

Beautify Your Mac Terminal with iTerm2, Zsh, and Starship

Do you spend a lot of time in the terminal and want to make it more visually appealing and productive? In this guide, I’ll walk you through how to transform your Mac terminal into a beautiful and efficient workspace using iTerm2, Zsh, and Starship. Whether you’re a developer, sysadmin, or just love tinkering with your setup, this step-by-step tutorial is for you.


Table of Contents


1. Introduction to iTerm2

iTerm2 is a powerful terminal emulator for macOS that offers extensive features and customization options. It’s a great alternative to the default macOS Terminal app and provides a smoother experience for developers and power users.


2. Downloading and Installing iTerm2

  1. Download iTerm2: Head over to the iTerm2 website and download the latest version.
  2. Install iTerm2: Once downloaded, open the .dmg file and drag iTerm2 to your Applications folder.

3. Setting Up Nerd Fonts

Nerd Fonts provide icons and glyphs for your terminal applications, making them visually appealing and functional.

  1. Download Nerd Fonts:
    • Visit the Nerd Fonts website.
    • Choose or search for a font like FiraMono Nerd Font.
    • Download the font file (usually a .zip archive).
  2. Install Nerd Fonts:
    • Unzip the downloaded file.
    • Select all the .ttf font files and double-click to open the Font window.
    • Click Install to add the fonts to your system.

4. Basic iTerm2 Configuration

  1. Open Preferences:
    • Open iTerm2 and go to Preferences (Cmd + ,).
  2. Customize Appearance:
    • Navigate to the Profiles tab.
    • Under the Colors section, choose a theme you like. For a modern look, try the Smoooooth color scheme.
  3. Set Font:
    • Go to the Text tab.
    • Choose a font like FiraMono Nerd Font Propo for better compatibility with icons and symbols.
    • Adjust the font size if needed.
  4. Enable Natural Editing:
    • Go to the Keys tab.
    • Select Natural Text Editing and click Remove to confirm and load the preset. This allows you to navigate between words using Cmd keys.

5. Configuring Zsh

Zsh (Z Shell) is a powerful shell that offers many improvements over the default Bash shell, including themes and plugins. Modern macOS versions already use Zsh as the default shell.

Optional Zsh Installation Steps

If you’re using an older macOS version or prefer to install Zsh manually:

  1. Install Homebrew (if not already installed):
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install Zsh:
    brew install zsh
    
  3. Set Zsh as your default shell:
    chsh -s $(which zsh)
    

6. Installing Oh My Zsh

Oh My Zsh is a framework for managing your Zsh configuration.

  1. Run the following command to install Oh My Zsh:
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

7. Adding Plugins for Zsh

Enhance your terminal experience by adding useful plugins like zsh-syntax-highlighting and zsh-autosuggestions.

  1. Install Plugins:
    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
    
  2. Configure Plugins:
    • Open the .zshrc file in a text editor:
      nano ~/.zshrc
      
    • Find the plugins array and add the plugins:
      plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
      
    • Save the file and restart your terminal or run:
      source ~/.zshrc
      

8. Adding Starship Prompt

Starship is a cross-shell prompt that is fast, customizable, and minimalistic.

  1. Install Starship:
    brew install starship
    
  2. Configure Starship:
    • Open the .zshrc file in a text editor:
      nano ~/.zshrc
      
    • Add the following line at the end of the file:
      eval "$(starship init zsh)"
      
    • Save the file and restart your terminal or run:
      source ~/.zshrc
      

9. Using a Starship Template

To simplify customization, use a pre-configured Starship template.

  1. Create the Starship configuration directory and apply a preset:
    mkdir -p ~/.config && starship preset gruvbox-rainbow -o ~/.config/starship.toml
    
  2. Customize the prompt further by editing the ~/.config/starship.toml file. You can find more presets here.

10. Bonus: Configuring VS Code

If you use VS Code with its integrated terminal, ensure the font settings are updated.

  1. Open VS Code and go to Settings (Cmd + ,).
  2. Search for Font Family and set FiraMono Nerd Font Propo for both:
    • Editor: Font Family
    • Terminal › Integrated: Font Family

11. Wrap-Up

That’s it! You’ve successfully transformed your Mac terminal into a beautiful and productive environment using iTerm2, Zsh, and Starship.

Let me know in the comments if you have any questions or suggestions for future tutorials. Happy coding!




Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • Introduction to Basic Control System
  • Brew and Conda package list with size information