こんにちは、ナナオです。

最近は寒いし乾燥するしで風邪が流行っていますね。気を引き締めていきましょう。

前回はznapのコミットが減ってきて大分下火になってしまった。。ということが分かりました。

ということで今回は新たにzshプラグインマネージャーのantidoteと、プロンプトのstarshipを使っていきましょう。

antidote

Starship

znapのアンインストールとantidoteの導入

まずはznapをアンインストールしていきます。

znapを導入した際とは逆の手順を踏めばいいです。

.zshrcに定義したznap関連のコマンドをコメントアウトします。

# znapの設定
# https://neer-engineer.com/525df03075fc272fc364d71a58b9f5a6/
# source ~/.znap/znap.zsh

# リポジトリの設定
# これがないとホームディレクトリ上にプラグインなどのリポジトリフォルダが出来上がってしまう
# zstyle ':znap:*' repos-dir ~/.znap/repos

# プロンプトの設定
# ohmyzshのテーマを使いたい場合は以下のように実装する
# znap prompt ohmyzsh/ohmyzsh random
# znap prompt sindresorhus/pure

# ohmyzsh関連の設定

# プラグインの設定
# znap source zsh-users/zsh-completions
# znap source marlonrichert/zsh-autocomplete
# znap source zsh-users/zsh-autosuggestions
# znap source zsh-users/zsh-syntax-highlighting
# znap source hlissner/zsh-autopair
# znap source marlonrichert/zsh-edit

そしたらznapを入れていたディレクトリを削除しましょう。

rm -rf ~/.znap

アンインストールはこれで完了です。

では早速antidoteを導入しましょう。

インストールはbrewで行いましょう。

brew install antidote

インストールしたら以下の一文を.zshrcに追加します。

# antidoteの設定
# パスは使用する環境によって異なるので注意!
source /home/linuxbrew/.linuxbrew/opt/antidote/share/antidote/antidote.zsh
antidote load

変更を適用します。

source ~/.zshrc

これでantidoteが使える状態になりました!

% antidote
antidote - the cure to slow zsh plugin management

usage: antidote [<flags>] <command> [<args> ...]

flags:
  -h, --help           Show context-sensitive help
  -v, --version        Show application version

commands:
  help      Show documentation
  load      Statically source all bundles from the plugins file
  bundle    Clone bundle(s) and generate the static load script
  install   Clone a new bundle and add it to your plugins file
  update    Update antidote and its cloned bundles
  purge     Remove a cloned bundle
  home      Print where antidote is cloning bundles
  list      List cloned bundles
  path      Print the path of a cloned bundle
  init      Initialize the shell for dynamic 

早速プラグインを追加していきましょう。

欲しいプラグインを~/.zsh_plugins.txtに書いていって…

zsh-users/zsh-completions
marlonrichert/zsh-autocomplete
zsh-users/zsh-autosuggestions
zsh-users/zsh-syntax-highlighting
zsh-users/zsh-history-substring-search
hlissner/zsh-autopair
marlonrichert/zsh-edit

再度shellを開きなおすと適用されます!

% exec $SHELL -l
# antidote cloning marlonrichert/zsh-edit...
# antidote cloning hlissner/zsh-autopair...
# antidote cloning marlonrichert/zsh-autocomplete...
# antidote cloning zsh-users/zsh-autosuggestions...
# antidote cloning zsh-users/zsh-history-substring-search...
# antidote cloning zsh-users/zsh-syntax-highlighting...
# antidote cloning zsh-users/zsh-completions...

めちゃくちゃ楽ですね。

あと地味にプラグインファイルを分けることができるのがうれしいポイント。

starshipの導入

この調子でstarshipも導入しちゃいましょう。

starshipはmiseでインストール可能です。

mise use -g starship

brewでも可能です。

brew install starship

.zshrcに以下の設定を追加します。

# starshipの設定
eval "$(starship init zsh)"

あとはshellを再起動すれば適用されます。

exec $SHELL -l

ぶっちゃけこのままでも十分ですが、カスタマイズしたい場合は~/.config/starship.tomlに設定を追記すればいいようです。

Configuration | Starship

感想

antidoteもstarshipも簡単にセットアップすることができて大変満足です。

カスタマイズすることがあったらまた記事にしようと思います。