Skip to content

Instantly share code, notes, and snippets.

@derhuerst
Last active July 19, 2024 05:46
Show Gist options
  • Save derhuerst/12a1558a4b408b3b2b6e to your computer and use it in GitHub Desktop.
Save derhuerst/12a1558a4b408b3b2b6e to your computer and use it in GitHub Desktop.
Installing the Z Shell (zsh) on Linux, Mac OS X and 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 update
sudo apt upgrade
sudo apt 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.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.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 sh -c "echo $(which zsh) >> /etc/shells" && chsh -s $(which zsh)
@vanessarowe
Copy link

could someone help me please?

I downloaded home-brew and I keep trying to download ZSH but it keeps showing me this message

/Users/vanessarowe/.zshrc:source:75: no such file or directory: /Users/vanessarowe/.oh-my-zsh/oh-my-zsh.sh
vanessarowe@Vanessas-MacBook-Air ~ %

what do I do?

@derhuerst
Copy link
Author

@vanessarowe Hm, it seems your system is a bit broken as well. The error message is not related to ZSH itself but to Oh my ZSH which is a plugin system for ZSH.

Because it complains about .oh-my-zsh missing in your home directory, I assume that you don't have Oh my ZSH installed but a reference to it in the ZSH config file .zshrc.

You could remove the Oh my ZSH reference from line 75 of .zshrc in your home directory and try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment