6

A Comprehensive Guide to Setting Up Your Mac Terminal with iTerm 2 and Zsh

 3 months ago
source link: https://medium.com/%E6%95%B8%E6%93%9A%E4%B8%8D%E6%AD%A2-not-only-data/macos-%E7%9A%84-terminal-%E5%A4%A7%E6%94%B9%E9%80%A0-iterms-oh-my-zsh-%E5%85%A8%E6%94%BB%E7%95%A5-77d5aae87b10
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Introduction

If you're a Mac user who wants to take your terminal experience to the next level, this guide is for you. We'll cover everything from installing essential packages to configuring iTerm 2 and Zsh, as well as recommending some must-have plugins.

1. Installing Essential Packages

To get started, we'll need to install a few essential packages using Homebrew, a package manager for macOS. Open your Terminal and run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once Homebrew is installed, we can use it to install iTerm 2, a powerful terminal emulator. Run the following command:

brew install iterm2

2. Configuring iTerm 2

Once iTerm 2 is installed, open it and navigate to the following location to set your terminal theme:

Preferences -> Profiles -> Colors -> Color Presets

There are many themes to choose from, but I recommend Solarized Dark with the Foreground brightness increased to 70%.

3. Installing Zsh

Next, we'll install Zsh, a popular shell that offers many features and customization options. Run the following command:

brew install zsh

4. Installing Oh-my-zsh

Oh-my-zsh is a framework for managing your Zsh configuration. It makes it easy to install and manage plugins and themes. To install Oh-my-zsh, run the following command:

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

5. Configuring Oh-my-zsh

Once Oh-my-zsh is installed, it will ask you if you want to make Zsh your default shell. Press y and enter to confirm.

To change your theme, open your .zshrc file and replace the line ZSH_THEME="robbyrussell" with the following:

ZSH_THEME="agnoster"

6. Installing Powerline Fonts

To display certain symbols correctly in your terminal, you'll need to install a Powerline font. There are many to choose from, but I recommend Meslo Dotted for Powerline. To install it, run the following command:

brew cask install font-meslo-for-powerline

Once the font is installed, open Font Book and enable it. Then, in iTerm 2, navigate to the following location to change your font:

Preferences -> Profiles -> Text -> Font -> Meslo Dotted for Powerline

7. Recommended Plugins

Here are a few plugins that I highly recommend:

  • Powerlevel9k: A powerful theme that provides a lot of information in your prompt.
  • Zsh-autosuggestions: Provides auto-completion for commands and arguments.
  • Zsh-syntax-highlighting: Adds syntax highlighting to your commands.
  • Navi: A command-line history manager.
  • Autojump: Allows you to quickly jump to frequently used directories.

To install these plugins, add the following lines to your .zshrc file:

plugins=(powerlevel9k zsh-autosuggestions zsh-syntax-highlighting navi autojump)

Conclusion

That's it! You've now successfully set up your Mac Terminal with iTerm 2 and Zsh. Enjoy the improved functionality and customization options!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK