Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 760
Kevin Suttle Avatar asked Aug 20 '12 05:08

Kevin Suttle


People also ask

Which command will update the zsh package if it is already installed in Linux?

Then you can either run chsh -s /usr/local/bin/zsh or go to System Preferences > Users & Groups > right click your user > Advanced Options... > and then change "Login shell". Load up a terminal and check you're now in the correct version with echo $ZSH_VERSION .

How do I set zsh as default shell on Mac?

You can change the default shell that new Terminal windows and tabs open with. In the Terminal app on your Mac, choose Terminal > Preferences, then click General. Under “Shells open with”, select “Command (complete path)”, then enter the path to the shell you want to use.

How do I change from zsh to Bash on Mac?

Hold the Ctrl key, click your user account's name in the left pane, and select “Advanced Options.” Click the “Login Shell” dropdown box and select “/bin/bash” to use Bash as your default shell or “/bin/zsh” to use Zsh as your default shell. Click “OK” to save your changes.


Video Answer


2 Answers

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 Link .

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 
like image 146
rodeinator Avatar answered Sep 20 '22 13:09

rodeinator


OK, so Burhan's comment reminded me of a situation where I had to explicitly add the path of the preferred version to my .bash_profile. Version 5.0.0 is in /usr/local/bin, so now the $PATH in my .bash_profile looks like so:

export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"

and now when I run which zsh, I get /usr/local/bin/zsh
and zsh --version returns zsh 5.0.0 (x86_64-apple-darwin12.0.0).

Woot! Hopefully this helps someone who is having the same problem.

like image 29
Kevin Suttle Avatar answered Sep 24 '22 13:09

Kevin Suttle