LoginSignup
9
8

More than 5 years have passed since last update.

プリインストールのzshからHomebrewのzshに移行した

Last updated at Posted at 2014-07-18

Why?

なんかよさげだったから(コナミカン
バージョンが上だし
アップデートもしやすそうだし
みんなそれでやってるっぽいから(結論)

実際にやってみる

とりあえずbrew info zshしてみる

Terminal
$ brew info zsh
zsh: stable 5.0.5 (bottled)
http://www.zsh.org/
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/zsh.rb
==> Dependencies
Required: gdbm ✔, pcre ✔
==> Options
--disable-etcdir
    Disable the reading of Zsh rc files in /etc
==> Caveats
Add the following to your zshrc to access the online help:
  unalias run-help
  autoload run-help
  HELPDIR=/usr/local/share/zsh/helpfiles

なるほど。デフォルトのzshが5.0.2だったから5.0.5でちょっと新しくなっている。
それから--disable-etcdirでデフォルトの設定を無効にできるらしい。思ったよりも簡単に出来そうだ。

いざインストール!!

Terminal
$ brew install --disable-etcdir zsh
==> Downloading https://downloads.sourceforge.net/project/zsh/zsh/5.0.5/zsh-5.0.5.tar.bz2
Already downloaded: /Library/Caches/Homebrew/zsh-5.0.5.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/zsh/5.0.5 --enable-fndir=/usr/local/Cellar/zsh/5.0.5/share/zsh/functions --enable-scriptdir=/usr/local/Cellar/zsh/5.0.5/share/zsh/scripts 
==> make install
==> make install.info
==> Caveats
Add the following to your zshrc to access the online help:
  unalias run-help
  autoload run-help
  HELPDIR=/usr/local/share/zsh/helpfiles
==> Summary
?  /usr/local/Cellar/zsh/5.0.5: 1070 files, 10M, built in 92 seconds

よしきた(一回試しにやったのがバレたかな)
次に、デフォルトのシェルのパスを変更する。
なんでもいいけどsudo vi /etc/shellsみたいな感じで/etc/shells/usr/local/bin/zshを追記する
*ロックがかかっているのでsudo

試しにターミナルに再起動をかけると、、

Terminal
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses --- 

設定ファイルがないよーという旨のメッセージが出てくる。

実際にはあるんだけど読み込まれなくなっている。これはbrew installするときにつけた--disable-etcdirというオプションが効いている証拠ですね。(/etc/zshenv$ZDOTDIRを設定していたのが読み込まれなくなっている)

なので元々あった設定を引き継ぎます
$ sudo mv /etc/zshenv ~/.zshenv

これで元々の設定で動くようになりました。

意外と楽に移行できたかも?

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8