Install oh my ZSH

1. What is ZSH? 🤔

Zsh is a powerful virtual terminal that can be used both as a system virtual terminal and as an interactive parser for scripting languages.

2. How do I check whether ZSH is installed? 🤔

  • Enter:
$ zsh --version
Copy the code
  • My output:
ZSH 5.7.1 (x86_64 - apple - darwin19.0)Copy the code

This means THAT I have ZSH installed

3. oh my zsh

(1) the installation

You can use curl or wget to install it with a single command.

  • The curl is installed
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Copy the code
  • Wget installed
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Copy the code

② Simple Configuration

Set a fixed theme
  • Terminal input:open ~/.zshrc
  • findZSH_THEME="robbyrussell"Here, the default theme has been setrobbyrussellTo modify the theme, please use this format:ZSH_THEME=" Theme name"
  • Save the file and reopen the terminal
Set random themes
  • Terminal input:open ~/.zshrc
  • Set the theme to:ZSH_THEME="random"
  • So every time you open the terminal, the theme is random.
  • Example: The next time you open the terminal, it will output something like this[oh-my-zsh] Random theme 'xiong-chiamiov' loadedThe statement, ‘Xiong -chiamiov’ is the theme name, if you like the theme, you can set it in your.zshrc.
View the topic name

Oh my ZSH comes with some default themes by default and is stored in the ~/.oh-my-zsh/themes directory. We can view these topics:

$ cd ~/.oh-my-zsh/themes && ls
Copy the code

③ Uninstall OH my ZSH

$ uninstall_oh_my_zsh
   Are you sure you want to remove Oh My Zsh? [y/N]  Y
Copy the code

④ Oh my ZSH auto update prompt accidentally turned off the solution

$ upgrade_oh_my_zsh
Copy the code

2. Install Autojump

Plug-in function: fast jump between directories, want to go to which directory directly J + directory name, no more frequent CD!

1. Installation procedure

  • Enter:
$ brew install autojump
Copy the code
  • Output:
= = > Downloading https://homebrew.bintray.com/bottles/autojump-22.5.3.catalina.bo # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Pouring Autojump - 22.5.3. Catalina. Bottle. Tar. Gz = = > Caveats to Add the following line to your ~ /. Following the or ~ /. ZSHRC file (the and remember to source the file to update your current session): [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh If you use the Fish shell then add  the following line to your ~/.config/fish/config.fish: [ -f /usr/local/share/autojump/autojump.fish ]; and source /usr/local/share/autojump/autojump.fish zsh completions have been installed to: / usr/local/share/ZSH/site - functions provides the = = > the Summary 🍺 / usr/local/Cellar/autojump / 22.5.3:20 files, 169.3 KBCopy the code

  • According to the prompt, in~/.zshrcAdd:
 [ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
Copy the code
  • usesourceCommand to update the configuration file:
$ source ~/.zshrc
Copy the code
  • So you can use yourcdHistory, usejCommand to jump to the target directory quickly, without having to jump multiple timescd~

3, installing Zsh-syntax -highlighting

Plug-in features: This package provides syntax highlighting for shell ZSH. It allows you to highlight commands entered into the interactive terminal at the ZSH prompt. This helps to check commands before running them, especially in catching syntax errors.

Example: When you type a command, if the command does not exist, it appears in red. Otherwise, it will turn green.

1. The document

  • The ZSH — syntax highlighting”

2. Installation procedure

  • Enter:
$ brew install zsh-syntax-highlighting
Copy the code
  • Output:
= = > Downloading https://homebrew.bintray.com/bottles/zsh-syntax-highlighting-0.7.1.catal # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # = = > 100.0% Pouring ZSH -- syntax highlighting - 0.7.1. Catalina. Bottle. Tar. Gz = = > Caveats To activate the syntax highlighting. add the following at the end of your .zshrc: source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh If you receive "highlighters directory not found" error message, you may need to add the following to your .zshenv: Export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR = / usr/local/share/ZSH - syntax highlighting/highlighters = = > the Summary 🍺 / usr/local/Cellar/ZSH -- syntax highlighting / 0.7.1:27 files, 164.4 KBCopy the code

  • in~/.zshrcAdd:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Copy the code
  • usesourceCommand to update the configuration file:
$ source ~/.zshrc
Copy the code

Install zsh-autosuggestion

Plug-in function: When you enter a command, it prompts you to automatically complete the command (the gray part). Press TAB (→) to complete the command.

1. The document

  • The ZSH – autosuggestions

2. Installation procedure

  • Enter:
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
Copy the code
  • Output:
Cloning into '/Users/xxx/.zsh/zsh-autosuggestions'... remote: Enumerating objects: 11, done. remote: Counting objects: 100% (11/11), done. remote: Compressing objects: 100% (10/10), done. remote: Total 2396 (delta 2), reused 3 (delta 1), pack-reused 2385 Receiving objects: 100% (2396/2396) and 545.28 KiB | 5.00 KiB/s, done. Resolving deltas: 100% (1533/1533), and done.Copy the code
  • in~/.zshrcAdd:
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
Copy the code
  • usesourceCommand to update the configuration file:
$ source ~/.zshrc
Copy the code

5. Reference materials

  • Oh My Zsh, setup, theme configuration method

  • Oh-my-zsh install autojump, zSH-Autosuggestion, and zsh-synchro-highlighting