1. Basic Introduction

  • See another Shell blog post for more details.
  • Bash and ZSH are shell command interpreters delivered with MAC terminals. Early MacOS use bash interpreter by default. In MAC OS 10.15, ZSH interpreter is officially recommended.
  • ZSH was originally called Z Shell. Also a shell, compatible with the most commonly used shell such as bash commands and operations, and has many enhancements, strong customization.
  • The oh-my-zsh tool simplifies the process of configuring ZSH. The oh-my-zsh tool helps us organize some common ZSH extensions and themes, as well as github addresses

2. How to use bash and ZSH

2.1 Switching method:

  • Switch bash:chsh -s /bin/bash
  • Switch the ZSH:chsh -s /bin/zsh
  • It can also be set manually in the system preference Settings of the terminal APP.

2.2 Reading environment configuration file:

  • Config file read by bash:~/.bash_profilefile
  • Configuration file read by ZSH:~/.zshrcfile
  • If you don’t want to reconfigure the.zshrc file when switching from bash to ZSH, you can add it to the.zshrc filesource ~/.bash_profile;Read the configuration directly from the.bash_profile file.

3. Oh – my – ZSH:

3.1. Installation:

  • Enter in the terminal ZSH interpretersudo curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | shTo install oH-my-zsh, download the installation script from Github.

3.2. Theme Modification:

  • Open the ~/.zshrc file and configure the item**ZSH_THEME**The oh-my-zsh theme configuration is provided on the GitHub Wiki page for oh-my-zshList of topics.
  • When set to ZSH_THEME=randomA random theme is used every time the terminal is opened.
  • The default theme for ZSH isrobbyrussell, used for a period of time found that is not so easy to use, recommendedysThe theme.

3.3 Installing plug-ins:

  • Code highlighting plugin ZSH -syntax-highlighting:git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
  • Zsh-autosuggestions for historical commandsgit clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
  • Z: Fast access to directories and direct add.
  • Web-search: enables the terminal to search for web pages.
  • Extract: Compression can be done directly with X, built-in.
  • Wd: maps the directory.
  • Sudo: Press ESC twice to add sudo command at the beginning of the command.
  • Encode64: Base64 encoding, built-in.
  • Urltools: URL encoding tool, including URlencode and URldecode.
  • Download the plugin and add it to the ~/.zshrc file:
plugins=(
    git
    z
    web-search
    zsh-autosuggestions
    zsh-syntax-highlighting
)
Copy the code

Reference documents: xiaozhou.net/learn-the-c…