What is the definitive way to install/upgrade/set the default version of ZSH?

Kevin Suttle picture Kevin Suttle · Aug 20, 2012 · Viewed 16.6k times · Source

OSX Mountain Lion ships with ZSH 4.3.1 in /bin/zsh. After downloading, ./configure, make, make check, and make install-ing version 5.0.0,

which zsh still returns /bin/zsh/

and zsh --version still returns zsh 4.3.11 (i386-apple-darwin12.0)

Items of note to help answerers:
I had no errors running the install commands.

In /usr/local/bin, I have these 3 files:
-rwxr-xr-x 2 kevinsuttle admin 622K Aug 20 00:59 zsh
-rwxr-xr-x 2 kevinsuttle admin 622K Aug 20 00:59 zsh-5.0.0
-rwxr-xr-x 1 kevinsuttle admin 622K Aug 20 00:50 zsh.old

My $PATH
$ echo $PATH
/Users/kevinsuttle/.rbenv/shims:/Users/kevinsuttle/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

Questions I need answered:
1. What is the cleanest way to install ZSH? (From git, homebrew, curl-ing source?)
2. Does it matter where you run the install commands?
3. How do I upgrade or override the version of ZSH that ships with Mountain Lion?
4. Is this why people end up using oh-my-zsh?

Answer

rodeinator picture rodeinator · Aug 27, 2012

You have to set your default shell in OSX with:

chsh -s /usr/local/bin/zsh $USER

Relogin to OSX and it should work!

Homebrew way

I recommand you to use homebrew. It makes things much easier. Install homebrew, like described on http://mxcl.github.com/homebrew/ .

Homebrew installs your stuff in /usr/local/bin, so make sure /usr/local/bin comes before /usr/bin .

Add the following line in ~/.zshrc and ~/.bashrc :

PATH="/usr/local/bin:/usr/local/sbin:$PATH"

Install zsh:

brew install zsh

Set your default shell to zsh:

chsh -s /usr/local/bin/zsh $USER

Finally set permission to use zsh from brew installation. Add "/usr/local/bin/zsh" to "/etc/shells" file to allow zsh. Else you'll get an error "You are not authorized to run this application. The administrator has set your shell to an illegal value."

echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells

I recommand to fix the zsh environment bug in OSX. Rename /etc/zshenv to /etc/zshrc

sudo mv /etc/{zshenv,zshrc}

Relogin to OSX and it should work!

If you have trouble, type:

brew doctor