LoginSignup
2
1

More than 3 years have passed since last update.

【zsh】zinitなるものを使ってみる

Posted at

初書:2021/03/26

前書き

zshで補完機能を入れてみるかあとふと思い立ったので、入れてみることにした。
軽く調べてみると、zinitというものを使用するといいらしい。

zinitとは

Zinitは、GitHubや他のサイトからすべてをインストールできる柔軟で高速なZshellプラグインマネージャーです。

GitHub - zdharma/zinit: Flexible and fast Zsh plugin manager with clean fpath, reports, completion management, Turbo, annexes, services, packages.より、google翻訳による日本語

つまり、Zshellに入れるプラグイン管理です。homebrewとかphpでいうcomposerとかそんな感じのやつ?

インストール

公式サイトに書いてあるおすすめのやり方をそのまま実行してみる

% sh -c " $( curl -fsSL https://raw.githubusercontent.com/zdharma/zinit/master/doc/install.sh ) "

# 前略

▓▒░ Would you like to add 4 useful plugins - the most useful annexes (Zinit extensions that add new functions-features to the plugin manager) to the zshrc as well? It will be the following snippet:

# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
    zinit-zsh/z-a-rust \
    zinit-zsh/z-a-as-monitor \
    zinit-zsh/z-a-patch-dl \
    zinit-zsh/z-a-bin-gem-node

-n ▓▒░ Enter y/n and press Return:

途中で止まった。これは.zshrcに書き込んでもいいか?という内容なのでyにしておく。

インストールが完了したら、ターミナルを再起動する

最初に起動するときは何か色々出てくるが、2回目以降はなさそう。

zinitを最新の状態にする

% zinit self-update

これだけ。

プラグインをインストールしてみる

結構色々な種類があるようなので、今回は最初の目標である補完機能系を入れてみる

zsh-syntax-highlighting

コマンド入力で、色付けしてくれるプラグイン。不明なコマンドだと赤文字になるため、間違えていることが実行しなくてもわかるようになる。

GitHub - zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh.

コマンドで入れるのかと思いきやそうではない。
.zshrcを直接編集し、以下の1行を入れる

.zshrc
zinit light zsh-users/zsh-syntax-highlighting

保存したらターミナルを再びリロードする。そうするとダウンロードが入る。

zsh-autosuggestions

コマンドの予測をして、灰色でお知らせしてくれるプラグイン。
予測通りのコマンドを入力するときは、十字キーの右を押せばそのまま入力される。

これも直接編集で入れる。

.zshrc
zinit light zsh-users/zsh-autosuggestions

終わりに

記述時点では2つしかプラグインを入れていないが、これで今は物足りそう。
もし何か増える予定があれば増やすかも。

参考サイト

zinitでzsh環境をいい感じにしたメモ - Qiita

参考予定サイト

Zplugin (zinit) を使ってみる - おのかちお's blog
【zsh高速化】え~、そんなプラグインマネージャーがあるんだったらもっと早く教えてよ、と姉が怒り出した - Zinit (旧名Zplugin) - Qiita

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1