From 43e3ce2765e05954ee76cbb382bc289aeca6b625 Mon Sep 17 00:00:00 2001 From: Robert Morrison Date: Tue, 11 Apr 2023 22:42:43 +0100 Subject: [PATCH] refactor(prompt): Add hook in the conventional way Change how I add the `vcs_info` function call to the `precmd` hook. Using add-zsh-hook allows me to have multiple hook functions on `precmd` and makes it clear what is done for each hook when listing them --- prompt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prompt b/prompt index c6f0686..29d4151 100644 --- a/prompt +++ b/prompt @@ -22,12 +22,12 @@ zstyle ':vcs_info:git*' check-for-changes true zstyle ':vcs_info:git*' formats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%}שׂ %{%f%}%b %u%c)" zstyle ':vcs_info:git*' actionformats "-(%{%F{203}%} %{%f%}%s:%{%F{2}%}שׂ %{%f%}%b %u%c)(%a)" -## set precmd to get vcs_info -## precmd runs before every prompt -precmd() { +## do precmd stuff +_vcsinfo() { vcs_info - setTermTitle "($(whoami)@$(hostname) $(pwd))" } +add-zsh-hook precmd _vcsinfo + PROMPT="╭╼(%{%F{81}%}%n%{%F{245}%}@%{%F{206}%}%m %{%F{245}%}%2~%{%F{259}%})─(%(?.😎.😞 %?))"$'\n'"╰┤" export RPROMPT='${vcs_info_msg_0_}'