LoginSignup
4
1

More than 1 year has passed since last update.

【powerlevel10k】ターミナル起動時に表示される警告メッセージを解消したい

Last updated at Posted at 2022-03-26

きっかけ

powerlevel10kをダウンロードし、yes/noに答えていって「よし使えるぞ!」と思ったら、ターミナルを開くたびに以下のようなエラーが出てしまいました。
これを解決するのに記事が見あたらなかったので、ここに載せておきます。

[WARNING]: Console output during zsh initialization detected.

When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.

You can:

  - Recommended: Change ~/.zshrc so that it does not perform console I/O
    after the instant prompt preamble. See the link below for details.

    * You will not see this error message again.
    * Zsh will start quickly and prompt will update smoothly.

  - Suppress this warning either by running p10k configure or by manually
    defining the following parameter:

      typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet

    * You will not see this error message again.
    * Zsh will start quickly but prompt will jump down after initialization.

  - Disable instant prompt either by running p10k configure or by manually
    defining the following parameter:

      typeset -g POWERLEVEL9K_INSTANT_PROMPT=off

    * You will not see this error message again.
    * Zsh will start slowly.

  - Do nothing.

    * You will see this error message every time you start zsh.
    * Zsh will start quickly but prompt will jump down after initialization.

For details, see:
https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt

-- console output produced during zsh initialization follows --

原因

まず、きちんと警告文を読みます。
すると、この警告文を消すには2択設定の仕方があるみたいですね。
つまるところ、一つ目の推奨設定である
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
これを設定すれば

    * You will not see this error message again.
    * Zsh will start quickly but prompt will jump down after initialization.

となるらしく、二つ目の
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
を設定すれば

    * You will not see this error message again.
    * Zsh will start slowly.

になるみたいです。このPOWERLEVEL9K_INSTANT_PROMPT設定がどうなってるか確認しましょう。
https://github.com/romkatv/powerlevel10k/issues/457
このissueで見つけたコマンドなのですが、
typeset -pm 'POWERLEVEL9K_*|ZSH_VERSION'
と打つと、powerlevel10kに設定している環境変数の状態を確認できるみたいです。
今回は警告に出てきたPOWERLEVEL9K_INSTANT_PROMPTの状況を確認してみます。
スクリーンショット 2022-03-27 8.32.06.png
すると、設定がverboseになっています。
これが警告文のようにquietoffになってないのが原因です。

解決策

問題はどうやってこれを設定するかです。
それは、powerlevel10kの設定ファイルの.p10k.zshを編集します。

vim ~/.p10k.zsh

すると、

  # Instant prompt mode.
  #
  #   - off:     Disable instant prompt. Choose this if you've tried instant prompt and found
  #              it incompatible with your zsh configuration files.
  #   - quiet:   Enable instant prompt and don't print warnings when detecting console output
  #              during zsh initialization. Choose this if you've read and understood
  #              https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
  #   - verbose: Enable instant prompt and print a warning when detecting console output during
  #              zsh initialization. Choose this if you've never tried instant prompt, haven't
  #              seen the warning, or if you are unsure what this all means.
  typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose

ありました。これを推奨のquietにします。そして設定をsourceで反映させてターミナルを再起動すると

source ~/.p10k.zsh

スクリーンショット 2022-03-27 8.38.59.png

無事消えてくれました。

最後に

普通に設定したはずなのになんでデフォでこの警告出るんやろ、、、
てか、ドキュメントもエラーもそうだけど、しっかり文章読むの大事やなぁ。と思いました。

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