Skip to content

Instantly share code, notes, and snippets.

@junjanjon
Created November 9, 2022 10:14
Show Gist options
  • Save junjanjon/9d57833aadb7c3f993e2950b5e6c22b5 to your computer and use it in GitHub Desktop.
Save junjanjon/9d57833aadb7c3f993e2950b5e6c22b5 to your computer and use it in GitHub Desktop.
Z shell のフック関数を一時無効化したい。

Z shell でプロンプトに vcs_info(git ブランチ情報)を表示している。 各プロンプトの前のフック precmd で実現している。

大きなリポジトリにいるときなどはブランチ情報を取得するのに時間がかかるため無効化したい。

以下の記事に同じようなケースが書かれていた。 https://stackoverflow.com/questions/42109673/how-to-remove-a-z-shell-precmd-function

precmd_functions の配列にある関数が precmd で実行される。 なので precmd_functions から該当のフック関数を削除すればいい。

自分の場合、使っているフック関数は1種類だけだったので以下をスニペットに追加した。

precmd_functions=()

ZSH 公式ドキュメント

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment