Boost your Terminal with Zsh extensions

Sep 8, 2024

Zsh or Z Shell is a powerful customizable shell that providers plenty features out of the box. And what makes it powerful is its extensions and plugins along with some cli tools. Making the terminal experience more efficient and enjoyable.

Before We Start:

  1. This guid is going to use the Oh-My-Zsh which is:

    Oh My Zsh is an open source, community-driven framework for managing your Zsh configuration
    Oh-My-Zsh

    To install it you can use wget or curl:

    • wget:
      shell
      sh -c "$(wget https://raw.githubusercontent.com/ohmyZsh/ohmyZsh/master/tools/install.sh -O -)"
    • curl:
      shell
        sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyZsh/ohmyZsh/master/tools/install.sh)"
  2. I will use Debian as my OS, all installation scripts will only work on Debian based linux distributions (Don't worry I'll include the official websites & installations if you are not using Debian based Linux distributions).

Zsh Plugins

For Lazy People Like me:
I will Include a Github Repository for automated installation process in the end of the section. So feel free to skip the manual installation.

  1. zsh-autosuggestions

    It suggests commands as you type based on history and completions.
    zsh-autosuggestions

    zsh-autosuggestions preview
    • Use the right arrow key to complete the command.

    To install it you have to run the following command.

    zsh
    git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

    Then you will need to add to the list of plugins in the .zshrc file, typically It is located in the home directory ~/.zshrc. Open it with any text editor and add the plugin like this:

    ini
    plugins=(
      # other plugins...
      zsh-autosuggestions
    )

    Then you have to start a new terminal session.

    You can also restart it with a single command:

    zsh
    source ~/.zshrc
  2. zsh-syntax-highlighting

    This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.
    zsh-syntax-highlighting

    zsh-syntax-highlighting preview

    The same procedure is followed. Run the command:

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

    Then add it to plugins list:

    ini
    plugins=(
      # other plugins...
      zsh-syntax-highlighting
    )

    Finally restart the terminal session to activate it.

  3. Autocomplete for Zsh

    This plugin for Zsh adds real-time type-ahead autocompletion to your command line, similar to what you find desktop apps. While you type on the command line, available completions are listed automatically; no need to press any keyboard shortcuts.
    Press Tab to insert the top completion or to select a different one.
    Autocomplete for Zsh

    zsh-syntax-highlighting preview zsh-syntax-highlighting preview zsh-syntax-highlighting preview zsh-syntax-highlighting preview zsh-syntax-highlighting preview
    • You can navigate through the suggestions using the arrow keys and use Tab To select one:

      zsh-syntax-highlighting preview

    To install I will provide the way i installed it if It did not work check the official installation guide.

    zsh
    git clone https://github.com/marlonrichert/zsh-autocomplete.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autocomplete

    Then add it to the plugins list:

    ini
    plugins=(
      # other plugins...
      zsh-autocomplete
    )

    And lastly restart the terminal session.

  4. This is a clean-room implementation of the Fish shell's history search feature, where you can type in any part of any command from history and then press chosen keys, such as the UP and DOWN arrows, to cycle through matches.
    zsh-history-substring-search

    zsh-history-substring-search preview

    To install it run the following:

    zsh
    git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search

    Then add it to the plugins list:

    ini
    plugins=(
      # other plugins...
      zsh-history-substring-search
    )

    And also restart the terminal session:

Automated Installation script

Here is a GitHup Repository created by me to automate the process. The Repository called dot-zsh.

dot-zsh repository preview

It Includes Two parts:

  1. Oh-My-Zsh Installer.
  2. Plugins Installer.

Here is how to use it:

  1. Clone the Repository

    Clone this repository to your local machine:

    bash
    git clone https://github.com/syntaxbox/dot-zsh
    cd dot-zsh
  2. Run the Installation Script

    Execute the install.sh script to install Oh-My-Zsh, plugins, set up .zshrc, and make zsh the default shell

    zsh
    chmod +x install.sh
    ./install.sh
  3. Install Plugins only

    If you already installed Oh-My-Zsh, You can directly install the plugins by running the install-plugins.sh script instead of the install.sh script:

    zsh
    chmod +x install-plugins.sh
    ./install-plugins.sh

Conclusion

These are the plugins that I personally use daily.

Make sure to check out the official documentation for each plugin to see the customizations and the tweaks that you can make.

I will be updating this post whenever I find my self using a new plugin. See you around :)