ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes. Since it’s based on the same shell as Bash, ZSH has many of the same features, and switching over is a breeze.
So Why Use It?
ZSH has too many features to list here, some just minor improvements to Bash, but here are some of the major ones:
- Automatic cd: Just type the name of the directory
- Recursive path expansion: For example “/u/lo/b” expands to “/usr/local/bin”
- Spelling correction and approximate completion: If you make a minor mistake typing a directory name, ZSH will fix it for you
- Plugin and theme support: ZSH includes many different plugin frameworks
Plugin and theme support is probably the coolest feature of ZSH and is what we’ll focus on here.
If you’re on macOS and have Homebrew installed (which you should), you can install ZSH with a single command:
brew install zsh
Also for macOS users, you should probably use iTerm instead of the native terminal, as it has much better color support (plus a lot of other features).
If you’re on Linux, the commands can vary by the distro, but it should be a default package in your package manager. You can consult this guide if you’re having trouble.
If you’re on Windows, you may not even have Bash in the first place. You can follow this guide to set that up and enable ZSH.
Oh-My-Zsh is the most popular plugin framework for ZSH, and it comes with many built-in plugins and themes as well. There are also a couple of other plugin frameworks, including Antigen, which is a full package manager for ZSH, but Oh-My-Zsh has loads of plugins built right in and does its job well.
Oh-My-Zsh has a simple install script you can run:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
From there, you can enable and disable plugins by adding them to your .zshrc file, located in your ~ directory.
You can get a full list of plugins on the Oh-My-Zsh repository.
There are plenty of themes to go around, but powerlevel9k is by far the coolest. It adds a right-aligned info box, integration with git and command history, incredible customization, and wraps it all up in a slick interface based on the powerline plugin for vim.
You’ll want to use iTerm on macOS, or any terminal with 24-bit color, to get the most out of powerlevel9k (or any ZSH theme, really).
To set up powerlevel9k (if you installed Oh-My-Zsh) just clone the repository into the .oh-my-zsh custom themes folder:
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
Then you need to enable it in .zshrc:
After that, source your .zshrc, and you should see the changes applied.
If you want, you can customize the default prompt by defining POWERLEVEL9K_LEFT_PROMPT_ELEMENTS in your .zshrc. Here’s mine, with a minimal prompt:
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs dir rbenv) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(root_indicator background_jobs status load)
You can find the full documentation for powerlevel9k on the repo.
|Files||tar · pv · cat · tac · chmod · grep · diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm|
|Processes||alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg|
|Networking||netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami · w · iptables · ssh-keygen · ufw|
- › How to Use the time Command on Linux
- › How to Open the Terminal on a Mac
- › How to Change Your Default Shell on Linux with chsh
- › How to Change the Default Shell to Bash on macOS Catalina
- › What Is the Bash Shell, and Why Is It So Important to Linux?
- › New Wired Nest Doorbell Has More Features in a Smaller Package
- › Google Home App Has a New Look and More Powerful Automation
- › Asus’ New Desktop PC Has Ports for USB Type-C And… PS/2?