Macのターミナル構築でやったこと

Mac miniを購入し久しぶりにMacの環境構築をしたので覚え書きとしてやったことを残していく。
自分の次回の環境構築を楽にする目的なので、個人の好みも多分に含めていく。

iTerm2をインストール
https://iterm2.com/ からiTerm2をダウンロード。
ダウンロード後はインストーラーを起動して表示される手順に従ってインストール。

Homebrewをインストール
iTerm2からHomebrewをインストール。
https://brew.sh/ja/ に書いてあるコマンドをコピーして実行。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
上記コマンドを実行し終えると最後に下記が出るので、書いてあることに従って3つのコマンドを実行。
==> Next steps:
- Run these commands in your terminal to add Homebrew to your PATH:
echo >> /Users/{ホームディレクトリ名}/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/{ホームディレクトリ名}/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
最後にbrewコマンドを実行してインストール動作確認。
brew --version

Oh My Zshをインストール
https://ohmyz.sh/ に書いてあるcurlコマンドをコピーして実行。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Zshをデフォルトのターミナルに設定
下記2コマンドを実行。
brew install zsh
chsh -s /usr/local/bin/zsh
実行後に一度 exit
してターミナルを再起動。

Zshテーマ Powerlevel10k をインストール
Oh My Zshからインストールしたいので、https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#oh-my-zsh の手順を参照。
まず下記コマンドを実行。
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
その後 vim
で ~/.zshrc
を開き、 ZSH_THEME
の記載がある行の値を "powerlevel10k/powerlevel10k"
に変更。
vim ~/.zshrc
値を変更したら下記を実行し ~/zshrc
を再読み込み。
source ~/.zshrc
実行するとPowerlevel10kの初回設定ウィザードが立ち上がり、下記の流れで設定が進む。
- Meslo Nerd Fontのインストールをするか聞かれるので
y
を入力してインストール - インストールが完了するとiTerm2を再起動するよう促されるので一度iTerm2を閉じて再起動
- 設定ウィザードの続きとしてインストールしたフォントの確認と見た目の設定が始まるので設問に回答していく

Zshプラグインを追加
zsh-autosuggestions
↓Oh My Zshからのインストール方法
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
↑を実行後、 ~/.zshrc
の plugins={}
に zsh-autosuggestions
を追加。
plugins=(
# other plugins...
zsh-autosuggestions
)
zsh-syntax-highlighting
↓Oh My Zshからのインストール方法
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
↑を実行後、 ~/.zshrc
の plugins={}
に zsh-autosuggestions
を追加。
plugins=( [plugins...] zsh-syntax-highlighting)