Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing the Z Shell (zsh) on Linux, Mac OS X and Windows

Installing zsh – the easy way

The Z shell (zsh) is a Unix shell [...]. Zsh can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh.

Z shell – Wikipedia

Read more about ZSH at An Introduction to the Z Shell.

Choose one of the following options.

Instructions for Mac
Instructions for Linux
Instructions for Windows

Installing zsh on Linux

Some Linux systems come preloaded with zsh. You can check if it exists as well as its version by writing zsh --version in a terminal window. In case this zsh version is ok for you, you're done now!

Determine on which Linux distribution your system is based on. See List of Linux distributions – Wikipedia for a list. Most Linux systems – including Ubuntu – are Debian-based.

Debian-based linux systems

Open a terminal window. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install zsh

You can use zsh now.

Red Hat-based linux systems

Open a terminal. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo yum upgrade
sudo yum install zsh

Suse-based linux systems

Open a terminal. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo zypper upgrade
sudo zypper install zsh

You can use zsh now.

More information

How to install the zsh shell in Linux; how to set it as a default login shell

Installing zsh on a Mac

OS X comes preloaded with zsh. You can check its version by writing zsh --version in a terminal window. In case this zsh version is ok for you, you're done now!

If you want the latest and greatest, use Homebrew: Proceed with the following steps to install a recent version.

Step 1 – Install Homebrew

Open a terminal window.

Homebrew [...] simplifies the installation of software on the Mac OS X operating system.

Homebrew – Wikipedia

Copy & paste the following into the terminal window and hit Return.

ruby -e "$(curl -fsSL https://raw.zshhubusercontent.com/Homebrew/install/master/install)"
brew doctor

You will be requested to install the Command Line Developer Tools from Apple. Confirm by clicking Install. After the installation finished, continue installing Homebrew by hitting Return again.

Step 2 – Install zsh

Copy & paste the following into the terminal window and hit Return.

brew install zsh

You can use zsh now.

Optional step 3 – default shell

To set zsh as your default shell, execute the following.

sudo -s 'echo /usr/local/bin/zsh >> /etc/shells' && chsh -s /usr/local/bin/zsh
@neo

This comment has been minimized.

neo commented Nov 16, 2016

Windows 10 now has bash which makes the it easier.

@elliott-beach

This comment has been minimized.

elliott-beach commented Jan 26, 2017

Tried the OSX install script and got an error:
ruby -e "$(curl -fsSL https://raw.zshhubusercontent.com/Homebrew/install/master/install)"

curl: (6) Could not resolve host: raw.zshhubusercontent.com

@yuseferi

This comment has been minimized.

yuseferi commented Jan 28, 2017

And also for me

Tried the OSX install script and got an error:
ruby -e "$(curl -fsSL https://raw.zshhubusercontent.com/Homebrew/install/master/install)"

curl: (6) Could not resolve host: raw.zshhubusercontent.com

@yuseferi

This comment has been minimized.

yuseferi commented Jan 28, 2017

@e-beach

brew install zsh
then
sudo -s 'echo /usr/local/bin/zsh >> /etc/shells' && chsh -s /usr/local/bin/zsh

Worked for me
Now I have zsh :)

@vjyanand

This comment has been minimized.

vjyanand commented Jan 29, 2017

use /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" instead.

@ilhamdoanggg

This comment has been minimized.

ilhamdoanggg commented Apr 29, 2017

i was installed a git bash on windows and can i change git bash with zsh themes?

@rueTH

This comment has been minimized.

rueTH commented May 15, 2017

@e-beach @zhilevan
I encountered that very same issue! For me, it was quickly resolved, though:
Prior to pasting the above into the terminal, I had used:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-- meaning I had installed Homebrew according to the instructions on their actual site. It appears that version and the version instructed above are just two different roads leading to the same destination. As was the case for me, there's a chance you may already have a version of Homebrew installed.
I have only been diving into the dev game since the start of the year (and until today was only familiar setting things up on PC/Linux), so rather than potentially leading you astray, I suggest you check out https://brew.sh/ for guidance on all things Homebrew.

Or, if you are the reckless or impatient sort, you can do what I did and press on by entering brew doctor into the terminal. If you have Homebrew already, it should be immediately evident. Boom.

**ATTN: I am no seasoned vet, and I hope those more knowledgable will correct any misinformation I have supplied & elaborate on the rest!

@mscheel

This comment has been minimized.

mscheel commented May 27, 2017

@derhuerst Mac instructions require updating, see: https://gist.github.com/mscheel/1c8e956d0b842ff42551a60b99cdf303 for revisions, thanks for putting this together. The revised instructions work for me on Sierra.

@a2ron

This comment has been minimized.

a2ron commented Sep 20, 2017

$ ruby -e "$(curl -fsSL https://raw.zshhubusercontent.com/Homebrew/install/master/install)"
curl: (6) Could not resolve host: raw.zshhubusercontent.com
@gprestes

This comment has been minimized.

gprestes commented Oct 20, 2017

How to install on Mac:

  • Install Brew (https://brew.sh)
    Double check it before, but as of now the command is: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • brew install zsh
  • Profit
@CodefulDom

This comment has been minimized.

CodefulDom commented Oct 30, 2017

Third Step on Mac gives error of: zsh
/bin/bash: echo /usr/local/bin/zsh >> /etc/shells: No such file or directory
screen shot 2017-10-30 at 9 17 56 am

Just to be clear I know that I have it installed, I was just trying to make sure that it is the default.

@NemanjaMandic

This comment has been minimized.

NemanjaMandic commented Nov 3, 2017

This is not working on Mac:
curl: (6) Could not resolve host: raw.zshhubusercontent.com

@larsenwork

This comment has been minimized.

larsenwork commented Dec 23, 2017

@derhuerst Shouldn't it be githubusercontent instead of zshhubusercontent?

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@drewlustro

This comment has been minimized.

drewlustro commented Feb 26, 2018

Yep. zshhubusercontent is a typo.

Also @TheDom1's note is true too... I got the same error.

@XerxesNoble

This comment has been minimized.

XerxesNoble commented Apr 18, 2018

Installing on macOS High Sierra

# Install homebrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Install zsh
$ brew install zsh

# (optional) set default shell
$ chsh -s /bin/zsh

# Verify, open new terminal
$ echo $SHELL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment