From ef8e6271288e69f10e81dbe9ab81da091e00300d Mon Sep 17 00:00:00 2001 From: Jim Richter Date: Mon, 14 Jun 2021 10:55:31 +0200 Subject: [PATCH] feat: auto update repo --- configs/.zshrc | 2 ++ configs/zsh/update-repo.zsh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 configs/zsh/update-repo.zsh diff --git a/configs/.zshrc b/configs/.zshrc index a850e9a..d6ef4ad 100644 --- a/configs/.zshrc +++ b/configs/.zshrc @@ -68,6 +68,8 @@ fi # For wsl stay in the current dir when splitting panes? export PROMPT_COMMAND='printf "\e]9;9;%s\e\\" "$(wslpath -m "$PWD")"' +source $HOME/.dotfiles/configs/zsh/update-repo.zsh + # The next line updates PATH for the Google Cloud SDK. #if [ -f '/home/coder/downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/home/coder/downloads/google-cloud-sdk/path.zsh.inc'; fi diff --git a/configs/zsh/update-repo.zsh b/configs/zsh/update-repo.zsh new file mode 100644 index 0000000..affa459 --- /dev/null +++ b/configs/zsh/update-repo.zsh @@ -0,0 +1,15 @@ +if [ -d "~/.dotfiles" ]; then + + currentDir=$(pwd) + + VN=$(git describe --abbrev=7 HEAD 2>/dev/null) + + git update-index -q --refresh + CHANGED=$(git diff-index --name-only HEAD --) + if [ ! -z $CHANGED ]; then + cd ~/.dotfiles + git reset --hard origin/main + git pull origin main + zshu + fi +fi