diff options
author | Anton Khirnov <anton@khirnov.net> | 2020-11-24 17:17:12 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2020-11-24 17:17:12 +0100 |
commit | 420b61bf28bb9b8db166f5979a589547102258b8 (patch) | |
tree | 8886f3cdca7ee6795dccb0dfeb8d2ca913900378 /cron | |
parent | bee37840a646f03e834c92180ad366f382e2e9cc (diff) |
Add a bash prompt notification for dirty/outdated dotfiles.
Diffstat (limited to 'cron')
-rwxr-xr-x | cron/dotfiles_status | 21 |
1 files changed, 21 insertions, 0 deletions
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 |