From 420b61bf28bb9b8db166f5979a589547102258b8 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 24 Nov 2020 17:17:12 +0100 Subject: Add a bash prompt notification for dirty/outdated dotfiles. --- cron/dotfiles_status | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 cron/dotfiles_status (limited to 'cron') diff --git a/cron/dotfiles_status b/cron/dotfiles_status new file mode 100755 index 0000000..3fccb0a --- /dev/null +++ b/cron/dotfiles_status @@ -0,0 +1,21 @@ +#!/bin/bash + +# check that the dotfiles repository is up-to-date and clean +# otherwise create the dirty stamp file + +dotfiles_dir=~/.config/dotfiles +dirty_stamp=~/.local/var/dotfiles/dirty + +[ -d "${dotfiles_dir}" ] || (echo "no dotfiles dir" && exit 1) + +git -C "${dotfiles_dir}" fetch -q --all || (echo "error updating remote" && exit 1) +count=$(git -C "${dotfiles_dir}" rev-list --left-right --count '@{upstream}'...HEAD 2>/dev/null | grep -v '^0\s0$') + +git -C "${dotfiles_dir}" diff --exit-code >/dev/null +repo_dirty=$? + +if [[ -n "${count}" || $repo_dirty -ne 0 ]]; then + touch "${dirty_stamp}" +else + rm "${dirty_stamp}" +fi -- cgit v1.2.3