From f58e953488db98c32972df2802cf631f9d4dd21e Mon Sep 17 00:00:00 2001 From: Starfall Date: Tue, 29 Nov 2022 16:04:21 -0600 Subject: zsh: use add-zsh-hook for git info on prompt --- .config/zsh/prompt.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to '.config') diff --git a/.config/zsh/prompt.zsh b/.config/zsh/prompt.zsh index 81e3664..6ae208e 100644 --- a/.config/zsh/prompt.zsh +++ b/.config/zsh/prompt.zsh @@ -8,9 +8,12 @@ autoload -Uz vcs_info zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' actionformats '%F{purple}[%F{green}%b%F{olive}|%F{red}%a%F{purple}]%f ' zstyle ':vcs_info:*' formats '%F{purple}[%F{green}%b%F{purple}]%f ' -precmd () { + +get_git () { [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]] && vcs_info || vcs_info_msg_0_="" } +autoload -Uz add-zsh-hook +add-zsh-hook precmd get_git user="%n" if [[ -n "$SSH_CLIENT" || "$USER" == "root" ]]; then -- cgit