Big sur で zsh 移行と Homebrew アップグレード

2020/12/12

zsh の切り替え

$ chsh -s /bin/zsh
Zsh

ターミナルで再ログインして zsh が利用できることを確認します。

zsh になると、ターミナルのニュー力モードで「$」から「%」に変わります。

% cd
Zsh

起動スクリプトの移行

zsh の関連ファイルが作成されているので、bash で登録していた自分の設定は再度移行しておきましょう。

% ls -al |grep '.zsh*'
-rw-------    1 yoo   staff        245 12 12 13:49 .zsh_history
drwx------    5 yoo   staff        160 12 12 13:49 .zsh_sessions
-rw-r--r--    1 yoo   staff        198  9 25  2019 .zshrc

Zsh
bash zsh
~/.bash_profile ~/.zprofile
~/.bashrc ~/.zshrc
~/.bash_profile ~/.zprofile
~/.bash_logout ~/.zlogout

.bash_profile の bash 処理は無効

自分の場合 .bash_profile にカスタマイズ設定を記述していたので、.zprofile にコピーしました。

% cp .bash_proile .zprofile
Zsh

当然ながら bash に関する処理は動作しないないので、書き換えないし無効にします。

自分の場合、GCP CLI や AWS CLI の bashスクリプトが動作しているので、これらは手動で書き換えました。

GCP CLI の例

# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/yoo/gcp/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/yoo/gcp/google-cloud-sdk/path.zsh.inc'; fi

# The next line enables shell command completion for gcloud.
if [ -f '/Users/yoo/gcp/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/yoo/gcp/google-cloud-sdk/completion.zsh.inc'; fi
Zsh

AWS CLI の例

AWS:コマンド補完」参照

% autoload bashcompinit && bashcompinit
% complete -C '/usr/local/aws/bin/aws_completer' aws
Zsh

Homebrew

Homebrew のアップデートをしたら、Cask の shallow clone のエラーになりました。

 % brew update
Error: homebrew-core is a shallow clone. To `brew update` first run:
...
Zsh

その前に Big sur にしたので Xcode もアップデートする必要があります。よって Homebrew を 1からインストールして Xcode command line ツールをインストールします。。

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Zsh

この辺は、Xcode を最初にアップグレードしてもよいかと思います。/p>

brew update で Git コマンドで解消してくださいと、警告が出ていたのでこれを実行します。

% git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
Zsh

完了したら brew を update & upgrade します。

 % brew update
 % brew upgrade
Zsh