From cae1621fe7636dd4240a09cf479b792691f6322c Mon Sep 17 00:00:00 2001 From: Allianaab2m <56180684+Allianaab2m@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:35:34 +0900 Subject: [PATCH] Update .zshrc --- dot_zshrc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dot_zshrc b/dot_zshrc index 48cc331..1a0d780 100644 --- a/dot_zshrc +++ b/dot_zshrc @@ -1 +1,21 @@ +function is_dirty() { + local dotfiles_dir=$(chezmoi source-path) + test -n "$(git -C ${dotfiles_dir} status --porcelain)" || + ! git -C ${dotfiles_dir} diff --exit-code --stat --cached origin/main > /dev/null +} + +function warn_dirty() { + local dotfiles_dir=$(chezmoi source-path) + if is_dirty $? ; then + echo -e "\e[1;36m[[dotfiles]]\e[m" + echo -e "\e[1;33m[warn] DIRTY DOTFILES\e[m" + echo -e "\e[1;33m -> Push your local changes in $dotfiles_dir\e[m" + fi +} + +if [[ ! -o login ]]; then + # Avoid duplicate warning (See .config/zsh/.zprofile) + warn_dirty +fi + eval "$(sheldon source)"