Open1
Oh My Zsh
Oh My Zsh のインストールとカスタマイズ
1. Oh My Zsh のインストール
以下のコマンドを実行して、Oh My Zsh をインストールします。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
詳細は公式サイトを参照してください: Oh My Zsh Installation
2. Zsh のカスタマイズ
Zsh の設定ファイルを整理し、カスタマイズしやすい構成にします。
設定ディレクトリの作成
mkdir ~/.zsh
設定ファイルの移動
mv ~/.zshrc ~/.zsh/ohmy.zsh
mv ~/.zshrc.pre-oh-my-zsh ~/.zsh/extras.zsh
.zshrc
の作成
新しい touch ~/.zshrc
echo "source ~/.zsh/ohmy.zsh" >> ~/.zshrc
echo "source ~/.zsh/extras.zsh" >> ~/.zshrc
3. Powerlevel10k の導入
Powerlevel10k を Oh My Zsh のテーマとして設定します。
インストール
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
フォントのインストール
Powerlevel10kでは、Nerd Fontに対応したフォントが必要です。下の手順でインストールしてください。
Homebrewを使用したインストール(macOSの場合):
brew tap homebrew/cask-fonts
brew install --cask font-monaspace
brew install --cask font-hack-nerd-font
brew install --cask font-jetbrains-mono-nerd-font
brew install --cask font-fira-code-nerd-font
VSCode系(VSCodeやCursorなど) のターミナルで設定
VSCode の統合ターミナルで Nerd Fonts を有効にする手順:
-
設定を開く(
Cmd + ,
またはCtrl + ,
) - 検索バーに
terminal.integrated.fontFamily
を入力 -
terminal.integrated.fontFamily
に以下を設定:Monaspace Neon, Hack Nerd Font, FiraCode Nerd Font, JetBrainsMono Nerd Font
- VSCode を再起動
テーマの変更
~/.zsh/ohmy.zsh
を編集し、テーマを変更します。
- ZSH_THEME="robbyrussell"
+ ZSH_THEME="powerlevel10k/powerlevel10k"
Powerlevel10k の設定を開始するには、ターミナルで以下を実行してください。
p10k configure
4. おすすめプラグインの導入
以下のプラグインをインストールし、有効化します。
4.1 you-should-use
より適切なコマンドを提案するプラグイン。
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/you-should-use
4.2 zsh-completions
コマンド入力から予測し補完を提案するプラグイン。
git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions
4.3 zsh-autosuggestions
コマンド履歴から入力補完を提案するプラグイン。
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
4.4 zsh-syntax-highlighting
コマンドの構文をハイライト表示。
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
4.5 zsh-fzf-history-search
brew install fzf
fzfを使用して、履歴検索。
git clone https://github.com/joshskidmore/zsh-fzf-history-search ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-fzf-history-search
5. 公式プラグインの有効化
Oh My Zsh には多くの公式プラグインが用意されています。以下のプラグインを有効にすることを推奨します。
公式プラグインリスト
- git
- aliases
- history
- copyfile
- copypath
- docker
- docker-compose
- mise
- brew
- github
- golang
- ruby
- rails
プラグインの適用方法
~/.zsh/ohmy.zsh
を編集し、以下のように plugins
のリストに追加してください。
plugins=(
git
aliases
history
copyfile
copypath
docker
docker-compose
mise
brew
github
golang
ruby
rails
you-should-use
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
zsh-fzf-history-search
)
6. 設定の適用
すべての変更を適用するために、Zsh を再読み込みします。
source ~/.zshrc
これでカスタマイズした Oh My Zsh の設定が適用されます。