On this article, I’ll present you how one can set up zsh, then provide ten suggestions and methods to make you extra productive when working with it.
As internet builders, the command line is turning into an ever extra vital a part of our workflow. We use it to put in packages from npm, to check API endpoints, to push commits to GitHub, and plenty extra apart from.
My shell of selection is zsh. zsh is a extremely customizable Unix shell, that packs some very highly effective options equivalent to killer tab completion, intelligent historical past, distant file enlargement, and much more.
This can be a beginner-level zsh information which could be adopted by anyone (even Home windows customers, because of Home windows Subsystem for Linux). Nonetheless, in gentle of Apple’s announcement that zsh is now the standard shell on macOS Catalina, Mac customers would possibly discover it particularly useful.
Let’s get began.
Putting in zsh
I don’t wish to provide in-depth set up directions for every working system, however relatively some common tips as a substitute. For those who get caught putting in zsh, there’s loads of assist out there on-line.
On the time of writing, the present zsh model is 5.7.1.
Putting in zsh on macOS
Most variations of macOS ship with zsh pre-installed. You may verify if so, and in that case, which model you’re operating utilizing the command: zsh --version
. If the model is 4.3.9 or increased, try to be good to go (we’ll want at the least this model to put in Oh My Zsh afterward). If not, you’ll be able to comply with this guide to put in a newer model of zsh utilizing Homebrew.
As soon as put in, you’ll be able to set zsh because the default shell utilizing chsh -s $(which zsh)
. After issuing this command, you’ll must sign off, then log again in once more for the adjustments to take impact.
If at any level you determine you don’t like zsh, you’ll be able to revert to Bash utilizing chsh -s $(which bash)
.
Putting in zsh on Linux
On Ubuntu-based distros, you’ll be able to set up zsh utilizing sudo apt-get set up zsh
. As soon as the set up completes, you’ll be able to verify the model utilizing zsh --version
, then make zsh your default shell utilizing chsh -s $(which zsh)
. You’ll must sign off, then log again in for the adjustments to take impact.
As with macOS, you’ll be able to revert again to Bash utilizing chsh -s $(which bash)
.
For those who’re operating a non-Ubuntu-based distro, then take a look at the instructions for other distros.
Putting in zsh on Home windows
Sadly, that is the place issues begin to get somewhat difficult. Zsh is a Unix shell, and for it to work on Home windows, you’ll must activate Windows Subsystem for Linux (WSL), an surroundings in Home windows 10 and 11 for operating Linux binaries.
There are numerous tutorials on-line explaining how one can rise up and operating with zsh in Home windows 10. I discovered these two to be up-to-date and straightforward to comply with:
Word that it’s additionally potential to get zsh operating with Cygwin. Listed here are instructions for doing that.
First Run
Whenever you first open zsh, you’ll be greeted by the next menu.

If you choose (1)
, you’ll be taken to a menu that permits you to configure historical past, keybindings and a bunch of different issues. Nonetheless, I recommend deciding on (2)
, which is able to create a configuration profile with the advisable default settings.
Finding the Configuration File
Now let’s take a look on the file that zsh simply created. Enter your private home listing and open the .zshrc
file in your editor of selection. This file is run everytime you begin zsh and is the place the place any customized configuration lives.
Word: file names that start with a dot are hidden by default on most working methods, so that you’ll must make it seen earlier than you’ll be able to edit it. For those who’re unsure how, seek for “Present hidden dot recordsdata mac/Linux and so forth”.
We are able to show how this file works by creating an alias. Of their easiest type, aliases are terminal shortcuts for normal instructions. Add the next to the underside of .zshrc
and save the file:
alias myip="curl http://ipecho.web/plain; echo"
Restart your shell (for instance, by closing it then opening it once more), then sort myip
. Offering you’ve the cURL program put in, you need to see your present public IP tackle output to the terminal. For those who’d wish to experiment extra with aliases, take a look at 7 Super Useful Aliases to make your development life easier.
Shut the terminal by typing exit
, then find the .zsh_history
file, which can also be in your house listing. That is the place zsh shops a listing of your earlier terminal instructions. At present it ought to include two strains — myip
and exit
.
Word: we’ll be reloading our shell a number of occasions via out the tutorial. It’s also possible to do that with a command: supply ~/.zshrc
.
Verify Your Progress
By this level you need to have zsh put in and set as your default shell. For those who expertise any issues, strive creating a subject on Pylogix’s forums and ask for assist there.
Now let’s get into some suggestions.
1. Set up Oh My Zsh
For those who solely comply with certainly one of the following tips, it must be this one.
Oh My Zsh is a community-driven framework for managing your zsh configuration and comes bundled with 1000’s of useful capabilities, helpers, plugins and themes. Most of the following suggestions will depend on you having this put in.
As is defined on the mission’s residence web page, you’ll be able to set up it utilizing cURL or wget:
sh -c "$(curl -fsSL https://uncooked.github.com/robbyrussell/oh-my-zsh/grasp/instruments/set up.sh)"
sh -c "$(wget https://uncooked.github.com/robbyrussell/oh-my-zsh/grasp/instruments/set up.sh -O -)"
This assumes you’ve Git put in, which you hopefully do already. If not, you’ll be able to grab it from the project’s homepage.

As you’ll be able to see, from the publish set up message, Oh My Zsh created a backup of your .zshrc
file, then changed it with its personal model. Which means you’ll want to repeat over any customized configuration (equivalent to our myip
alias) to your new .zshrc
file.
2. Choose a Theme
For those who spend plenty of time within the terminal, it’s value investing some effort in making it visually interesting. Fortunately Oh My Zsh ships with a whole bunch of themes.
For those who look within the ~/.zshrc
file for the ZSH_THEME
variable, you’ll discover it’s set to robbyrussel
. That is the default theme that the creator of Oh My Zsh makes use of.
To put in a distinct theme, decide one from the hyperlink above and alter the worth of the ZSH_THEME
variable, earlier than restarting your shell. For instance, setting ZSH_THEME="avit"
will trigger Oh My Zsh to make use of the avit theme.
You may additionally like to change the colour scheme to your terminal. On my Linux machine, I might do that through Edit > Preferences > Colours. Eradicating the tick from Use colours from system theme, then deciding on Solarized darkish as a scheme, offers me a really interesting end in subsequent to no time.

Discover how the theme acknowledges that it’s in a Git repo, tells me which department I’m on, and shows a inexperienced tick to let me know that every little thing is updated.
I encourage you to take a look via the out there themes and discover one which fits you.
Troubleshooting
After I was testing this on WSL, I used to be seeing damaged characters in my terminal, as quickly as I put in Oh My Zsh. To treatment this, I needed to set up the Powerline fonts and inform my terminal to make use of them:
git clone https://github.com/powerline/fonts.git
Then open an admin PowerShell, navigate to the foundation of the repo and run:
.set up.ps1
If PowerShell blocks you from operating the script, then strive setting the ExecutionPolicy
as per this Stack Overflow answer. As soon as the fonts are put in, remember to set it again once more.
Lastly, proper click on on the terminal’s title bar, select Properties > Font and ensure a Powerline font is chosen. In testing, Deja Vu Sans Mono for Powerline labored nicely for me.
Additionally notice that a few the themes require Powerline fonts, whatever the working system. We’ll have a look at putting in certainly one of these themes (Agnoster) in the direction of the tip of the article.
3. Working with Historical past
One among my favourite Oh My Zsh options is the way in which that it enables you to search via your historical past. Think about that the contents of .zsh_history
appear like this:
cd Desktop
mkdir my-project
cd my-project
npm init -y
mkdir {src,construct}
contact index.js
For those who’re within the terminal and press the ↑ key, you’d anticipate to cycle via every of these historical past entries one after the other, proper? No shock there.
Nonetheless, Oh My Zsh permits you to enter the start of a command, then press the ↑ key to cycle via matching entries. So, within the above instance when you entered “mkdir” after which pressed the ↑ key, you’ll see “mkdir {src,construct}” displayed. For those who pressed it once more, you’ll then see “mkdir my-project”.
I exploit this characteristic on a regular basis. For example, once I wish to ssh right into a server and might’t keep in mind the precise credentials, I simply enter “ssh” and might cycle via current connections till I discover the proper one. Or, once I can’t keep in mind the precise syntax of a command, I can simply enter the primary few characters and cycle via any matches.
4. Autosuggestions FTW!
One other nice characteristic of Oh My Zsh is plugins. These add new options to your shell and increase its performance.
Oh My Zsh ships with hundreds of plugins for each conceivable use and we’ll have a look at a few of these later within the article. On this part nevertheless, I’d wish to introduce you to a 3rd celebration plugin referred to as autosuggestions. This implies instructions as you sort primarily based on historical past.
To put in, it’s essential to clone its repository into $ZSH_CUSTOM/plugins
. By default that is ~/.oh-my-zsh/customized/plugins
:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/customized}/plugins/zsh-autosuggestions
As soon as carried out, to activate it, hop into the ~/.zshrc
file and uncomment the next line:
# plugins=(git)
Then substitute git
with zsh-autosuggestions
:
plugins=(zsh-autosuggestions)
Restart your shell, and also you’ll discover that as you sort a command, Oh My Zsh will make ideas primarily based in your historical past. If the suggestion is the one you might be in search of, press the → key to just accept it. An actual time saver!

5. File Navigation with Oh My Zsh
One other superior factor about Oh My Zsh is how straightforward it makes it to navigate round your machine.
For instance, once you wish to change listing, it isn’t essential to enter the cd
command; cd Desktop
simply turns into Desktop
. And that works with paths, too: you’ll be able to enter /residence/jim/Desktop
and find yourself proper the place you needed to go.
Oh My Zsh has nice autocomplete, too. After getting began typing a path, you’ll be able to press TAB to have it increase a listing of all potential folders you’ll be able to navigate to. For those who proceed tabbing, you’ll be able to transfer via this record till you choose a folder by urgent Return. Urgent TAB once more after that may restart the method.

Lastly, it’s value mentioning that Oh My Zsh gives quite a few commands and aliases for working with, and navigating directories. For instance, typing ...
will transfer you up two directories and typing take <dir-name>
will create a brand new listing and navigate to it. Oh My Zsh additionally helps dynamic path completion, so typing (for instance) /h/j/De
and urgent Tab will increase the trail to /residence/jim/Desktop
. Cool, eh?
Bonus Tip: when you’re feeling lazy, you’ll be able to simply drag and drop a folder onto the terminal window and the trail can be expanded for you.
6. Navigate to Something Utilizing z
z is a handy plugin that builds a listing of your most frequent and up to date folders (it calls these “frecent”) and permits you to leap to them with one command. That is usually rather more handy than having to tab via a nested folder construction.
To put in the plugin, all it’s a must to do is add it to your .zshrc
file like so:
plugins=(z zsh-autosuggestions)
Then restart your terminal.
As soon as put in, z may have a brief studying part because it observes you navigating round your PC with the terminal. After some time, nevertheless, you’ll have the ability to sort z
adopted by any phrase that’s in your required listing path. The plugin will use fuzzy matching to determine which folder you wish to go to and increase the trail accordingly. If there’s a couple of risk, you’ll be able to tab via the choices as described within the earlier tip.
This won’t sound like an enormous deal, however you’ll have the ability to open a shell, sort z my-project
and have it increase the trail to /residence/jim/recordsdata/some/deeply/nested/listing/or/different/my-project
. Then once you’re in that listing, you’ll be able to sort z my-other-project
and have it increase the trail to /var/www/html/tasks/high/secret/my-other.mission
.
Word: the primary time I ran z, and tried to vary listing, I obtained the error_z_dirs:2: no such file or listing: /residence/jim/.z
. This was a one off, as z apparently wanted to make a .z
file in my residence listing. For those who run into any issues, this article has some suggestions.
7. Working with Git
Zsh contains some primary Git integration out of the field. For instance, when you sort git
and press the Tab key, zsh will helpfully spit out an extended record of potential git instructions. This turns into barely extra helpful when you sort git
, adopted by the primary couple of letters of the command you’re in search of. For instance git a
+ Tab produces this:
add -- add file contents to index
am -- apply patches from a mailbox
apply -- apply patch to recordsdata and/or to index
archimport -- import an Arch repository into git
archive -- create archive of recordsdata from named tree
Issues begin to get extra attention-grabbing once you set up the Oh My Zsh git plugin:
plugins=(git z zsh-autosuggestions)
This gives an entire bunch of aliases, in addition to some helpful capabilities for working with Git. Among the ones I exploit incessantly are:
gaa
–git add all
gdca
–git diff --cached
gp
–git push
gpf!
–git push --force
grhh
–git reset --hard
gst
–git standing
You possibly can additionally create an alias for a number of instructions without delay, by including the next to your .zshrc
file:
operate acp() {
git add .
git commit -m "$1"
git push
}
Now, once you’re in a Git repo, typing acp "a commit message"
will add all modified recordsdata, commit them with no matter commit message you specified, then push them to your distant. Credit score for this concept goes to Ali Spittel.
8. Get Instantaneous Suggestions on the State of a git Repo
On the high of the article, we activated a theme referred to as avit. When in a Git repo, this theme will show the department title, in addition to a cross or tick indicating whether or not every little thing department is up-to-date. I like with the ability to see this data at a look, and it’s undoubtedly an enormous step up from having to sort git standing
on a regular basis.
There are a few themes, nevertheless, that show this data in a extra intuitive method. My favourite is Agnoster. Let’s set up that now.
For Agnoster to render arrows and Git icons accurately, you’ll seemingly want to put in a Powerline-patched font. WSL customers can do that by following the directions within the troubleshooting section above. For macOS and Linux customers, installation instructions can be found in the project’s repo.
Mac customers on Excessive Sierra or later might must carry out some extra work to get these fonts to show. Except you might be on Catalina, this method is recommended. Catalina customers might want to set up a patched font and choose it of their terminal settings.
To check in case your terminal can show the entire needed characters, run the next command:
echo "ue0b0 u00b1 ue0a0 u27a6 u2718 u26a1 u2699"
The outcome ought to appear like the picture beneath.

After that, allow the theme by altering the next line in your .zshrc
file:
ZSH_THEME="agnoster"
Then restart the terminal. As soon as Agnoster is up and operating, you’ll have a extra intuitive view of the standing of any Git repository. You’ll additionally obtain visible suggestions as as to whether the earlier command succeeded or failed, and whether or not you might be working with elevated privileges.

Tip: when you don’t just like the person@host
a part of the immediate, you may make this disappear by including DEFAULT_USER=your_user_name
to the .zshrc
file.
9. Plugins, Plugins, Plugins
As talked about, Oh My Zsh ships with a lot of plugins. You actually ought to look via these and make investments a while studying these that may assist your workflow. To get you began, listed below are some widespread ones to pay attention to:
- cloudapp – uploads recordsdata and piped contents to the Cloudapp service. Outputs and copies the resultant URL to the clipboard.
- command-not-found: if a command isn’t acknowledged within the
$PATH
, this can use Ubuntu’s command-not-found package deal to search out it or recommend spelling errors (just for Ubuntu and openSUSE). - node: open the Node API, to your present model, in your browser.
- npm: provides autocompletion to npm.
- sudo: hitting ESC twice places sudo in entrance of the present command, or the final one if the command line is empty.
- vscode: makes interplay between the command line and the code editor simpler.
10. Key Combos
This isn’t a zsh particular tip, however to wrap up I needed to make you conscious of those 5 time-saving key combos.
- Ctrl + U: delete from the cursor to the beginning of the road.
- Ctrl + Ok: delete from the cursor to the tip of the road.
- Ctrl + W: delete from the cursor to the beginning of the previous phrase.
- Alt + D: delete from the cursor to the tip of the following phrase.
- Ctrl + L: clear the terminal.
For those who can memorize these, you’ll be stunned at how usually they turn out to be useful.
Conclusion
On this article, I’ve demonstrated how one can set up zsh (Z shell) and set it as your default shell. I’ve additionally confirmed how one can get essentially the most out of your new terminal with the Oh My Zsh framework. It’s my hope that, when you give these a strive for a few weeks, you’ll surprise the way you ever did with out them.
And don’t overlook: in case you have any issues with any of this, you’ll be able to jump over to Pylogix forums and ask for assist there. I’d even be completely satisfied to listen to if I missed something out — for instance, your favourite theme, plugin, alias, or productiveness tip.
You may hit me up both on the boards or on Twitter.
FAQs about Zsh (Z shell)
Zsh provides options like superior tab completion, spelling correction, customizable prompts, and extra scripting choices. It’s designed to boost person expertise and productiveness in comparison with conventional shells like Bash.
Sure, you should utilize Zsh on Home windows by putting in it via instruments like Cygwin, Home windows Subsystem for Linux (WSL), or Git Bash. Nonetheless, organising Zsh on Home windows would possibly contain some extra steps
Sure, Zsh can run Bash scripts, however some compatibility points would possibly come up as a consequence of syntax variations between the 2 shells. It’s a superb follow to validate and alter scripts to make sure they work accurately in Zsh.
Zsh themes decide the looks of your terminal immediate. They usually show helpful data like the present listing, Git standing, and extra. Oh My Zsh contains a wide range of themes you’ll be able to select from.
You may allow syntax highlighting by utilizing Zsh plugins like “zsh-syntax-highlighting.” Set up the plugin and add its activation command to your Zsh configuration file.
Sure, many Bash configurations could be tailored for Zsh. Nonetheless, Zsh has its personal syntax and options, so some modifications is perhaps needed to totally make the most of its capabilities.
You may customise your Zsh immediate by modifying the PS1 surroundings variable in your Zsh configuration file (normally ~/.zshrc
). Alternatively, utilizing frameworks like Oh My Zsh permits you to select and customise themes.
Zsh plugins are extensions that improve Zsh’s capabilities. They will present extra options like syntax highlighting, auto-suggestions, and improved completion for particular instructions or languages.
Zsh plugin managers like “Oh My Zsh,” “Zplug,” and “Antigen” make it straightforward to put in and handle plugins. Every supervisor has its personal setup directions, normally involving modifying your Zsh configuration file.
Oh My Zsh is a well-liked framework for managing Zsh configurations and plugins. It features a assortment of pre-built themes and plugins that you may simply allow or customise.
You may change your default shell to Zsh by operating the command chsh -s $(which zsh)
. This may replace your shell desire within the system’s person configuration.
Zsh is usually pre-installed on macOS and plenty of Linux distributions. If not, you’ll be able to set up it utilizing your system’s package deal supervisor. For instance, on Debian-based methods, you’ll be able to run sudo apt-get set up zsh
.
Zsh, quick for Z shell, is a sophisticated Unix shell that gives highly effective customization choices, improved scripting capabilities, and interactive options for command-line interfaces.
Configuring Zsh includes customizing numerous features of the shell to fit your preferences and wishes. Right here’s a step-by-step information on how one can configure Zsh:
Edit the Zsh Configuration File (.zshrc): The first configuration file for Zsh is positioned in your house listing and is known as .zshrc
(i.e., ~/.zshrc
). You may edit this file utilizing a textual content editor of your selection, equivalent to nano
, vim
, or gedit
.
Select a Zsh Framework or Plugin Supervisor (Non-compulsory): Zsh frameworks and plugin managers like Oh My Zsh, Prezto, and Zgen can simplify the configuration course of by offering pre-configured setups and straightforward administration of plugins and themes. You may select certainly one of these frameworks or handle every little thing manually.
Choose a Zsh Theme: Zsh themes management the looks of your terminal immediate. Many themes can be found, providing totally different types and data show choices. To alter your theme, find the ZSH_THEME
variable in your .zshrc
file and set it to the title of the specified theme, equivalent to ZSH_THEME="agnoster"
. Save the adjustments and restart your Zsh session or run supply ~/.zshrc
to use the brand new theme.
Set up and Handle Zsh Plugins (Non-compulsory): Zsh plugins can prolong the performance of your shell. For those who’re utilizing a framework like Oh My Zsh, you’ll be able to simply add and handle plugins. In your .zshrc
file, you’ll usually discover a part for configuring plugins. You may add or take away plugins as wanted, like plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
. Save the adjustments and restart your Zsh session or run supply ~/.zshrc
to activate the plugins.
Set Zsh Choices and Aliases: Customise Zsh by configuring numerous choices and creating aliases instantly in your .zshrc
file. To set choices, use the setopt
command (e.g., setopt nocasematch
). To create aliases, use the alias
command (e.g., alias ll='ls -al'
).
Customise the Immediate (Non-compulsory): For superior customization of your immediate’s look, modify the PS1
variable. This includes manually specifying the weather you need in your immediate, and there are lots of on-line assets and guides out there for creating customized prompts.
Save and Apply Modifications: After making your customizations, save the .zshrc
file, and both restart your Zsh session or run supply ~/.zshrc
to use the adjustments instantly.
Check and Refine: Check your customizations and make changes as wanted. Experiment with totally different themes, plugins, choices, and aliases to search out the setup that works greatest to your workflow and preferences.
Do not forget that configuration is a private course of, and you’ll tailor your Zsh surroundings to fit your particular wants and elegance. Zsh’s flexibility and the supply of assorted themes and plugins make it a flexible shell for configuring your command-line expertise.
Customizing Zsh permits you to tailor your shell surroundings to your particular wants and preferences. Right here’s how one can customise Zsh:
Edit the Zsh Configuration File (.zshrc): The first configuration file for Zsh is positioned in your house listing and is known as .zshrc
(i.e., ~/.zshrc
). You may edit this file utilizing a textual content editor of your selection, equivalent to nano
, vim
, or gedit
.
Select a Zsh Framework or Plugin Supervisor (Non-compulsory): Zsh frameworks and plugin managers like Oh My Zsh, Prezto, and Zgen can simplify the customization course of by offering pre-configured setups and straightforward administration of plugins and themes. You may select certainly one of these frameworks or handle every little thing manually.
Choose a Zsh Theme: Zsh themes management the looks of your terminal immediate. Many themes can be found, providing totally different types and data show choices. To alter your theme, find the ZSH_THEME
variable in your .zshrc
file and set it to the title of the specified theme. Save the adjustments and restart your Zsh session or run supply ~/.zshrc
to use the brand new theme.
Set up and Handle Zsh Plugins (Non-compulsory): Zsh plugins can prolong the performance of your shell. For those who’re utilizing a framework like Oh My Zsh, you’ll be able to simply add and handle plugins. In your .zshrc
file, you’ll usually discover a part for configuring plugins. You may add or take away plugins as wanted. Save the adjustments and restart your Zsh session or run supply ~/.zshrc
to activate the plugins.
Set Zsh Choices and Aliases: Customise Zsh by configuring numerous choices and creating aliases. You are able to do this instantly in your .zshrc
file. To set choices, use the setopt
command.
To create aliases, use the alias
command.
Customise the Immediate (Non-compulsory): You may additional customise the looks of your immediate by modifying the PS1
variable. This can be a extra superior customization that includes manually specifying the weather you need in your immediate. There are a lot of on-line assets and guides out there for creating customized prompts.
Save and Apply Modifications: After making your customizations, save the .zshrc
file, and both restart your Zsh session or run supply ~/.zshrc
to use the adjustments instantly.
Check and Refine: Check your customizations and make changes as wanted. You may experiment with totally different themes, plugins, choices, and aliases to search out the setup that works greatest to your workflow and preferences.
Do not forget that customization is a private course of, and you’ll tailor your Zsh surroundings to fit your particular wants and elegance. Zsh’s flexibility and the supply of assorted themes and plugins make it a flexible shell for customizing your command-line expertise.