Zsh Essentials: 5 Plugins to Amp Up Your Command Line Journey
Navigating Zsh: From Syntax Highlighting & Autosuggestions to Archive Management & URL Handling – Boosting Your Command Line Efficiency
Navigating the command line, especially with Zsh, offers a blend of efficiency and power. While its built-in features are impressive, diving into Zsh plugins opens doors to even more refined functionalities. Exploring this area, one discovers tools that seamlessly integrate, enhancing workflows and introducing new dimensions to usual tasks. The journey through Zsh's plugin ecosystem promises both new insights and nods to those familiar with its capabilities.
Getting Started with Zsh And Plugins
Zsh
, colloquially known as the “Z shell,” is a souped-up version of the Bourne Shell (sh). Even without plugins, Zsh boasts of features missing in sh
, such as:
Direct directory access: No need to type
cd
; just enter the directory name.Advanced completion: For example, type
kill java
, hit tab, and Zsh will list all PIDs for Java processes.Shared command history: Enter a command in one terminal, and it's available in the history of another.
However, the true strength of Zsh lies in its extensibility. But before delving into that, let's install Zsh.
If you're on Ubuntu or another Debian-based system, you can use apt
:
# Install zsh
$ sudo apt install zsh
# Check if everything works fine
$ zsh --version
zsh 5.9 (x86_64-ubuntu-linux-gnu)
Next, set Zsh as your default shell and reboot your system:
chsh -s $(which zsh)
With Zsh installed, what about plugins?
We'll start by installing Oh-My-Zsh, a renowned plugin framework for Zsh. Note: Oh-My-Zsh isn't available via apt
, so you'll need to run the following commands:
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.dh
sh install.sh
For peace of mind, you can visit GitHub to review the installation script before executing it. With everything set up, it's time to explore the world of Zsh plugins!
Exploring Five Essential Zsh Plugins
While we've touched upon the capabilities of Zsh and the potential of plugins, we haven't delved into the installation process for these plugins just yet. As we introduce the first essential plugin, we'll also walk you through the installation steps to ensure a seamless experience. So, let's step in and get started! 🔧
zsh-syntax-highlighting 🎨
This plugin is true to its name. zsh-syntax-highlighing brings IDE-esque syntax highlighting to your terminal.
Installing the plugin with Oh-My-Zsh is fairly easy:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Post-installation, enable the plugin by editing ~/.zshrc
:
plugins=(
zsh-syntax-highlighting
)
Fire up a new terminal, and voilà, the plugin comes alive!
zsh-autosuggestions 💡
While zsh-syntax-highlighting
minimizes errors, zsh-autosuggestions
is a time-saver. As you type commands, Zsh offers completion suggestions. Accept them with the ➡️ right arrow key.
You can install it via:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
and activate it like above by editing your .zshrc
:
plugins=(
zsh-syntax-highlighting
zsh-autosuggestions
)
The plugin can be configured to your needs, for example how the suggestions are created. Head over to the documentation on GitHub for further details.
extract 📦➡️📄📑
Ever struggled with remembering the exact order of parameters to unpack gzipped tarballs? I sure have! That's where extract
comes into play, and let me tell you, it's a game-changer. It effortlessly extracts just about any archive, no parameters required!
All you need to do is:
extract <your_archive_name>
And voilà! extract
handles everything for you. The range of archives it supports is genuinely astounding. Here are a few examples:
Variations of
tar
liketar.bz2
,tar.gz
,tar.lz
, and more.Common ones like
zip
,7z
.Even app files like
apk
(for Android) andipa
(for iOS).
Curious about the full range? Check out the complete list here.
If you're using Oh-My-Zsh, extract
is already there for you. Simply activate it in your ~/.zshrc
:
plugins=(
zsh-autosuggestions
zsh-syntax-highlighting
extract
)
universalarchive 📄📑➡️📦
After discussing how to effortlessly unpack archives with extract
, let's switch gears and talk about creating them. That's where universalarchive
shines. It's the other side of the coin, adeptly packing up files into a myriad of compression formats.
Using it is as straightforward as:
ua <format> <files>
ua tar.gz *.json
While it may not support as expansive a list of formats as extract
, it certainly covers the essentials: 7z
, gz
, tar.gz
, and more.
And if you're already on the Oh-My-Zsh bandwagon, integrating universalarchive
is easy. Simply add it to your plugins in ~/.zshrc
:
plugins=(
zsh-autosuggestions
zsh-syntax-highlighting
extract
universalarchive
)
Now, with extract
and universalarchive
, you're fully prepared to handle any archive task with ease.
urltools 🔗🔄
Handling URLs often requires encoding and decoding, especially when working with web projects or API integrations. This is where urltools
steps in, offering a seamless way to manage these tasks right from your terminal.
This plugin introduces two straightforward commands:
urlencode
: Converts a standard URL into its encoded format.urldecode
: Transforms an encoded URL back to its readable form.
urlencode 'https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code'
This will return the encoded version of the URL.
To revert or decode:
urldecode 'https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
This fetches the original URL, making it human-readable once more.
Setting up urltools
with Oh-My-Zsh is a breeze. Simply append it to your plugins list in ~/.zshrc
:
plugins=(
zsh-autosuggestions
zsh-syntax-highlighting
extract
universalarchive
urltools
)
Conclusion
Thank you for sticking with me through this post! I truly hope these plugins make your tasks a tad easier and save you some precious time.
If you found this article valuable, please leave a comment 💬 and share it with your network 📢.