brief introduction

  • Say goodbye to the mediocre terminal and create a personalized and efficient command line environment!
  • This article will lead you step by step to use zsh and oh my zsh to create your own efficient terminal.

 Create efficient terminal: zsh+oh my zsh

1、 Preparatory work

  1. Understand the basics

    • Be familiar with some basic terminal operations, such as cd, ls, pwd, etc.
    • Learn some basic Linux or macOS commands.
  2. Install necessary software

    • Make sure zsh is installed on your computer

       #Apt system sudo apt install zsh #Yum series sudo yum install zsh #Pacman series pacman -S zsh #Dnf system dnf install zsh
      Execute after installation chsh -s /bin/zsh Switch the default terminal to zsh, login again and take effect through the command echo $SHELL Check whether it is effective
    • Install oh my zsh. Refer to the following documentation: https://github.com/ohmyzsh/ohmyzsh?tab=readme -ov-file#basic-installation

       # curl sh -c "$(curl -fsSL  https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh )" # wget sh -c "$(wget -O-  https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh )" # fetch sh -c "$(fetch -o -  https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh )"
      Please use domestic gitee image if it cannot be downloaded due to network reasons

2、 Configure oh my zsh

  1. Replace default theme

    • Open configuration file: vim ~/.zshrc
    • Come here https://github.com/ohmyzsh/ohmyzsh/wiki/Themes Select your favorite built-in theme, such as: af-magic , the default theme is robbyrussell
    • Modify the following configuration:

       # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded,  run: echo $RANDOM_THEME # See  https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ZSH_THEME="af-magic"
    • Save and close the configuration file.
    • implement source ~/.zshrc take effect
  2. Enable plug-in

    • Open configuration file: vim ~/.zshrc
    • Come here https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins Select your favorite built-in plug-in, for example: git、web-search、jsontools、z
    • Modify the following configuration. By default, git is enabled after installation

       # Which plugins would you like to load? # Standard plugins can be found in $ZSH/plugins/ # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely,  as too many plugins slow down shell startup. #Plugins=(git) This line is enabled by default, and multiple plug-ins are separated by spaces plugins=(git web-search jsontools z)
    • Save and close the configuration file.
    • implement source ~/.zshrc take effect

3、 Efficient operation

  1. Powerful automatic completion

    • When you enter a command or file name, press TAB to complete it automatically.
    • use ctrl+n/p Move up and down in the completion options.
  2. Syntax highlighting

    • Commands, parameters, errors, etc. are displayed in different colors for easy reading.
  3. Git integration

    • It is more convenient to view branch status, submission history, quick submission and other operations.
  4. Themes and colors

    • Create personalized terminal interface according to your preference.

4、 Advanced skills

  1. Using the zsh autosuggestions plug-in

    • Provide more intelligent automatic completion suggestions, including commands, file names, paths, etc.
    • Reference link: https://github.com/zsh-users/zsh-autosuggestions

       git clone  https://github.com/zsh-users/zsh-autosuggestions  ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
  2. Using the zsh syntax highlighting plug-in

    • It provides richer syntax highlighting functions and supports multiple programming languages.
    • Reference link: https://github.com/zsh-users/zsh-syntax-highlighting

       git clone  https://github.com/zsh-users/zsh-syntax-highlighting.git  ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
  3. Using the powerlevel10k theme

    • Provide powerful theme customization function to create a cool terminal interface.
    • Reference link: https://github.com/romkatv/powerlevel10k

       git clone --depth=1  https://gitee.com/romkatv/powerlevel10k.git  ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

      Configuration reference:

 #Theme ZSH_THEME="powerlevel10k/powerlevel10k" #Plug in plugins=(git web-search jsontools z zsh-syntax-highlighting zsh-autosuggestions)

5、 Conclusion

Zsh and oh my zsh give you powerful terminal control ability, which helps you to be more efficient in programming, development, operation and maintenance. Use your imagination to create your own personalized and efficient terminal!

be careful:

  • This guide is only for reference, please adjust it according to your actual needs.
  • It is recommended that you back up your profile before making any changes.
  • For more information, please refer to the official documents of zsh and oh my zsh.

Reference link

GitHub - ohmyzsh/ohmyzsh
GitHub - zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh.
GitHub - zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh
Terminal environment: zsh, oh my zsh, prompt theme and 7 efficiency plug-ins - POLOXUE's BLOG
Centos 7 Install the higher version of the zsh tutorial
Article Contents