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)"