LoginSignup
3
1

More than 3 years have passed since last update.

Zsh zplug + prezto でプロンプトのカスタマイズ

Posted at

zshのplugin managerって種類が多く、何を使えばいいか。。
ひとまず、zplugから各pluginをインストールする方向でローカル環境を構築してみた。

ローカル環境

  • macOS Catalina 10.15.6
  • zsh version 5.7.1

まずzplugのインストール

  • homebrewから zplug をインストール
$ brew install zplug
==> Downloading https://github.com/zplug/zplug/archive/2.4.2.tar.gz
==> Downloading from https://codeload.github.com/zplug/zplug/tar.gz/2.4.2
##O#- #
==> Caveats
In order to use zplug, please add the following to your .zshrc:
  export ZPLUG_HOME=/usr/local/opt/zplug
  source $ZPLUG_HOME/init.zsh
==> Summary
:beer:  /usr/local/Cellar/zplug/2.4.2: 198 files, 369.8KB, built in 2 seconds
$

.zshrc編集

ZPLUG_HOME のexport

zplugインストール時の表示通り、以下 .zshrcに追記

  export ZPLUG_HOME=/usr/local/opt/zplug
  source $ZPLUG_HOME/init.zsh

入力補完plugin

以下、.zshrcに追記

zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "chrissicool/zsh-256color"

コマンドプロンプトをカスタマイズするためのprezto prompt

zplugからpreztoのprompt pluginを取り込むため、以下 .zshrcに追記

zplug "modules/prompt", from:prezto

.zshrc に記載したpluginのインストール

上記、記載したpluginを実際にインストール & ロードするため、以下 .zshrc に追記

if ! zplug check; then
    zplug install
fi

zplug load

コマンドプロンプトのテーマを選択する

prezto prompt のコマンドプロンプトをロードするため、以下、 .zshrc に追記
(プロンプトテーマは色々ありますが、 シンプルな minimal にしてみました。)

prompt minimal

.zshrc読み込み

最後に.zshrcをロードする

$ source ~/.zshrc

prezto promptの使い方

prompt テーマ

以下のコマンドで promptテーマ一覧が表示される

$ prompt -l
Currently available prompt themes:
agnoster cloud damoekri giddie kylewest minimal nicoulaj paradox peepcode powerlevel10k powerlevel9k powerline pure skwp smiley sorin steeef adam1 adam2 bart bigfade clint default elite2 elite fade fire off oliver pws redhat restore suse walters zefram

各テーマのプレビューも確認できる

試しに cluudテーマをプレビューしてみた。

$ prompt -p cloud

prompt_cloud_setup:38: command not found: pmodload
cloud theme:
☁  ~  command arg1 arg2 ... argn

cloud theme with parameters `✯':
✯  ~  command arg1 arg2 ... argn

cloud theme with parameters `> yellow red':
>  ~  command arg1 arg2 ... argn

テーマを変更する

adam1 テーマに変更してみた。

$ prompt adam1
xxxx@localhost ~ %

参考資料

3
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
3
1