summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Beattie <mike@ethernal.org>2018-05-27 19:59:00 +1200
committerMike Beattie <mike@ethernal.org>2018-05-27 19:59:00 +1200
commite6fb0c1bd2ef0368474c96b0e1dcc04a3260c10a (patch)
tree35f5cb6c102d89458509b4a6ff6bee6c0dacc967
parent72c99d53541e63563c17154a4b982755c72e8eb1 (diff)
ZSH: Check dotfiles repo for changes on login
Just checks for difference in hash for 'master' head Signed-off-by: Mike Beattie <mike@ethernal.org>
-rw-r--r--.zlogin11
1 files changed, 11 insertions, 0 deletions
diff --git a/.zlogin b/.zlogin
index 0a882e0..c398626 100644
--- a/.zlogin
+++ b/.zlogin
@@ -3,6 +3,17 @@ if [ -f $HOME/.zlogin.$(hostname) ]; then
source $HOME/.zlogin.$(hostname)
fi
+# check to see if git repository has been updated
+function () {
+ if command -v git >|/dev/null && git -C $HOME rev-parse >|/dev/null 2>&1 ; then
+ local local_head="$(git -C $HOME show-ref --hash --heads master)"
+ local origin_head="$(GIT_SSH_COMMAND="ssh -o BatchMode=yes -o ConnectTimeout=1" git -C $HOME ls-remote --heads origin master 2>|/dev/null | cut -f1)"
+ if [ "$local_head" != "$origin_head" ];then
+ print "$fg[blue]--= ${fg[red]}git repository differs from origin$fg[blue] =--$terminfo[sgr0]"
+ fi
+ fi
+}
+
# set terminal to clear after logout.
trap clear EXIT