Macの開発環境

Macで開発していて調子が悪いので環境を一度整理しました.まずはhomebrewをアンインストールしてインストールし直しました.
homebrewのインストール

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

無事インストールできたら何はさておきbrew doctorを実行します.
以下のようなエラーが出たのでとりあえず退避します.
Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
/usr/local/lib/libmecab.a
/usr/local/lib/libntfs-3g.a
/usr/local/lib/libntfs.a
/usr/local/lib/libublio.a

mkdir -p /usr/local/_lib
mv /usr/local/lib/libqmi_api.dylib /usr/local/_lib/

また,
Permission denied - /Library/Caches/Homebrew/Formula/zsh.brewing
のようなエラーが出たので

sudo chown -R username /Library/Caches/Homebrew/

で所有権を変えました.

Error: /usr/bin occurs before /usr/local/bin
のようなエラーが出たら

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

でパスを書きかえます.

これで大方エラーは解決できたので, zshをインストールしました.
無事インストールが終わりログインシェルをzshに変更しようとすると以下のようなエラーが出ました.
dyld: Library not loaded: /usr/local/lib/libncursesw.5.dylib
Referenced from: /usr/local/bin/zsh
Reason: image not found
解決方法は分からなかったのですが,

brew link --overwrite zsh

で直りました.

再びbrew doctorをしたところ次のようなエラーが出ました.
/usr/bin occurs before /usr/local/bin
なので.zshrcに

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

を書き込みました.

参考
http://dev.classmethod.jp/etc/modern-dev-environment-by-homebrew/