avatarUğur Taş

Summary

This article explores top Zsh plugins that can significantly boost terminal productivity for developers.

Abstract

The article titled "Terminal Productivity Booster Zsh Plugins" discusses various Zsh plugins that can enhance the productivity of developers who spend a significant amount of time working in the terminal. The plugins mentioned in the article include fast-syntax-highlighting or zsh-syntax-highlighting, zsh-autosuggestions, colorful files, zsh-completions, zsh-history-substring-search, and plugins to remember alias commands. The article provides a brief description of each plugin and explains how they can be installed and configured. The article also emphasizes the importance of striking a balance while installing plugins to avoid slowing down the shell.

Bullet points

  • The article discusses various Zsh plugins that can enhance the productivity of developers.
  • The plugins mentioned in the article include fast-syntax-highlighting or zsh-syntax-highlighting, zsh-autosuggestions, colorful files, zsh-completions, zsh-history-substring-search, and plugins to remember alias commands.
  • The article provides a brief description of each plugin and explains how they can be installed and configured.
  • The article emphasizes the importance of striking a balance while installing plugins to avoid slowing down the shell.
  • The article is aimed at developers who spend a significant amount of time working in the terminal.

Terminal Productivity Booster Zsh Plugins

For developers who spend a significant portion of their day working in the terminal, even small efficiency gains can translate into hours of saved time over the long run. While the default terminal experience on most systems is functional, it often lacks the polish and convenience features that can truly streamline your workflow. Enter Zsh plugins — lightweight scripts that extend the functionality of the Z Shell (Zsh), a powerful and highly customizable alternative to the default Bash shell.

In this article, we’ll explore some of the top Zsh plugins that can significantly boost your terminal productivity, making you a more efficient and effective developer.

Prerequisites

Before we begin, make sure you have the following installed:

If you did not install them before, you can check the first steps of the below article.

1- fast-syntax-highlighting or zsh-syntax-highlighting

Never struggle with typos or syntax errors again. This plugin provides real-time syntax highlighting for your command line, making it easier to spot mistakes and invalid commands at a glance. This plugin an optimized version of zsh-syntax-highlighting. With fast-syntax-highlighting, you’ll enjoy a visual coding experience right in your terminal.

You can clone the fast syntax highlighting below command.

git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git \
  ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting

If you prefer to use zsh-syntax-highlighting follow below steps.

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

When the command execution is over, you can check the plugin folder with below command.

ls $ZSH_CUSTOM/plugins

If the folder does not exist, rerun the git clone command.

After cloning the repo to $ZSH_CUSTOM/plugins path, add the plugin name to the plugins list in the .zshrc file. This step is valid for all installations. Don’t forget to update plugins list in .zshrc file.

Before adding plugin to plugins list.

After adding plugin to plugins list.

You can install this plugin with other zsh plugin managers with these commands.

# Using zinit
zinit light zsh-users/zsh-syntax-highlighting

# Using zplug
zplug "zsh-users/zsh-syntax-highlighting"

# Using Antigen
antigen bundle zsh-users/zsh-syntax-highlighting

2- zsh-autosuggestions

Tired of retyping the same commands over and over? zsh-autosuggestions intelligently suggests commands based on your command history and the current context. Simply hit the right arrow key to accept a suggestion, or keep typing to ignore it. This plugin can save you countless keystrokes and prevent repetitive strain injuries.

Plugins installation process is the same for this plugin as well. Copy the repo to plugins path. Add plugin name to plugins list in the .zshrc file.

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

.zshrc file should looks like this after adding zsh-autosuggestions

Before adding autosuggest to plugins list.

After adding autosuggest to plugins list.

# Using zinit
zinit light zsh-users/zsh-autosuggestions

# Using zplug
zplug "zsh-users/zsh-autosuggestions"

# Using Antigen
antigen bundle zsh-users/zsh-autosuggestions

3- Colorful Files

These plugins help you to differentiate file types by color. So it makes it easy to recognize same type of files easily.

Zsh Syntax Highlighting Filetypes

If you want to use a pure zsh plugin, you can use this as your choice.

git clone https://github.com/trapd00r/zsh-syntax-highlighting-filetypes
${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting-filetypes

Don’t forget to add plugin to .zshrc file

Auto-Color-ls

This plugin uses Colorls behind the scenes. So first you need to install colors. Run below commands one by one.

First install colorls if you don’t have it already

gem install colorls

then clone the plugin repository to custom plugins folder.

git clone https://github.com/gretzky/auto-color-ls ${ZSH_CUSTOM}/plugins/auto-color-ls

After cloning update .zshrc file and add plugin to plugins list. When you change your directory with cd command you will see icons. Also auto-color-ls lists files and folders with different colors. Here and example of it.

4- zsh-completions

Tab completion is a game-changer for efficient command-line usage, but the default completion options are limited. zsh-completions extends tab completion to a wide range of tools, programming languages, and frameworks, allowing you to navigate and use complex tools with ease.

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

Again add this plugin name to the plugin list and run source command.

plugins=(... zsh-completions)
source ~/.zshrc

When you add this plugin to the plugin list and open a new terminal, you can see the completions when you press the tab button. If there are too many possible completions you will get a prompt like this:

5- zsh-history-substring-search

Quickly find and re-use previous commands by typing just a part of the command you’re looking for. zsh-history-substring-search makes it a breeze to retrieve commands from your history, even if you can’t remember the exact syntax.

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

After cloning it, add plugin name to the plugin list in the .zshrc file and source the .zshrc file.

plugins=(... zsh-history-substring-search)

Now it is time to bind the search function with keys. UP and DOWN keys are suitable to bind search. Because those are already used to get previous commands.

  • Run cat -v in your favorite terminal emulator to observe key codes. (NOTE: In some cases, cat -v shows the wrong key codes. If the key codes shown by cat -v don't work for you, press <C-v><UP> and <C-v><DOWN> at your ZSH command line prompt for correct key codes.)
  • Press the UP arrow key and observe what is printed in your terminal.
  • Press the DOWN arrow key and observe what is printed in your terminal.
  • To terminate the cat -v press the Control and C keys simultaneously.
  • Then bind the observed keys. If you see ^[[A and ^[[B in the screen run below commands. If you see something else replace those values.
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

After key binding you will be able to search history easily. You can verify it by typing part of a command that you already run and pressing UP and DOWN keys.

Such as, if you run git command before, when you type git and press UP and DOWN arrows you will see your previous git commands.

If this does not work for you after key bindings, you can try using terminfo. Try to run these commands:

bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down

In some cases [OA and [OB are correct values, even if these were not the observed values. If you are having trouble with the observed values, give these a try.

6- Don’t forget alias Anymore

Do you have many alias commands but you forget them sometimes? Or do you use a zsh plugin like git that provides you with a good amount of useful aliases but you forget them? Then you absolutely need these plugins(at lease one of them).

These two plugins helps you to remember alias you already have. When you run a command they find the existing alias you can use instead of the command. So you can easily remember and continue using your alias.

You can see the outputs of both plugins in this screenshot. Alias tips provide short and targetted prompts. You should use provides detailed and colored prompts to indicate existing alias.

For Alias tips run below command and clone the repo to plugins folder.

git clone https://github.com/djui/alias-tips.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/alias-tips

Then add the plugin to plugins list in the .zshrc file.

plugins=(... alias-tips)

You can use other plugin managers as well.

# Using zgen
zgen load djui/alias-tips
zgen save

# Using zplug
zplug "djui/alias-tips"

# Using Antigen
antigen bundle djui/alias-tips

For You Should Use, clone the repository with the below command.

git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use

Then add the plugin to .zshrc file

plugins=(...    you-should-use  ...)

You can also install You Should Use plugin with zplug , antigen , and zgen

# Using zgen
zgen load "MichaelAquilina/zsh-you-should-use"

# Using zplug
zplug "MichaelAquilina/zsh-you-should-use"

# Using Antigen
antigen bundle "MichaelAquilina/zsh-you-should-use"

You can customize prompt messages of both plugins. check their GitHub repositories to get up-to-date configurations.

These are just a few examples of the many productivity-enhancing Zsh plugins available. By carefully curating and installing the plugins that best suit your workflow, you can transform your terminal into a powerhouse of efficiency, allowing you to focus on writing code and solving problems rather than wrestling with cumbersome command-line interfaces.

Remember, while plugins can be incredibly useful, it’s essential to strike a balance and avoid installing too many, as an overabundance of plugins can potentially slow down your shell. Start with the plugins that address your most pressing pain points, and gradually add more as needed.

In the fast-paced world of software development, every second counts. By supercharging your terminal with these productivity-boosting Zsh plugins, you’ll not only save time but also cultivate a more enjoyable and streamlined development experience.

👏 Thank You for Reading!

👨‍💼 I appreciate your time and hope you found this story insightful. If you enjoyed it, don’t forget to show your appreciation by clapping 👏 for the hard work!

📰 Keep the Knowledge Flowing by Sharing the Article!

✍ Feel free to share your feedback or opinions about the story. Your input helps me improve and create more valuable content for you.

✌ Stay Connected! 🚀 For more engaging articles, make sure to follow me on social media:

🔍 Explore More! 📖 Dive into a treasure trove of knowledge at Codimis. There’s always more to learn, and we’re here to help you on your journey of discovery.

Terminal
Zsh
Oh My Zsh
Plugins
Productivity
Recommended from ReadMedium