As web developers, the command line is becoming an ever more important part of our workflow. We use it to install packages from npm, to test API endpoints, to push commits to GitHub, and lots more besides.
In this article I’ll show you how to install zsh, then offer ten tips and tricks to make you more productive when working with it.
This is a beginner-level guide which can be followed by anybody (even Windows users, thanks to Windows Subsystem for Linux). However, in light of Apple’s announcement that zsh is now the standard shell on macOS Catalina, mac users might find it especially helpful.
Let’s get started.
I don’t want to offer in-depth installation instructions for each operating system, rather some general guidelines instead. If you get stuck installing zsh, there is plenty of help available online.
At the time of writing the current zsh version is 5.7.1.
Most versions of macOS ship with zsh pre-installed. You can check if this is the case and if so, which version you are running using the command:
zsh --version. If the version is 4.3.9 or higher, you should be good to go (we’ll need at least this version to install Oh My Zsh later on). If not, you can follow this guide to install a more recent version of zsh using homebrew.
Once installed, you can set zsh as the default shell using:
chsh -s $(which zsh). After issuing this command, you’ll need to log out, then log back in again for the changes to take effect.
If at any point you decide you don’t like zsh, you can revert to Bash using:
chsh -s $(which bash).
On Ubuntu-based distros, you can install zsh using:
sudo apt-get install zsh. Once the installation completes, you can check the version using
zsh --version, then make zsh your default shell using
chsh -s $(which zsh). You’ll need to log out, then log back in for the changes to take effect.
As with macOS, you can revert back to Bash using:
chsh -s $(which bash).
If you are running a non-Ubuntu based distro, then check out the instructions for other distros.
Unfortunately, this is where things start to get a little complicated. Zsh is a Unix shell and for it to work on Windows, you’ll need to activate Windows Subsystem for Linux (WSL), an environment in Windows 10 for running Linux binaries.
There are various tutorials online explaining how to get up and running with zsh in Window 10s. I found these two to be up-to-date and easy to follow:
- How to Install and Use the Linux Bash Shell on Windows 10 – follow this one first to install WSL
- How to Use Zsh (or Another Shell) in Windows 10 – follow this one second to install zsh
When you first open zsh, you’ll be greeted by the following menu.
The post 10 Zsh Tips & Tricks: Configuration, Customization & Usage appeared first on SitePoint.