diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2022-12-05 01:39:05 +0100 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2022-12-05 01:39:05 +0100 |
commit | e9f52f24c29f798d618c6e8e68ceabbd86bd0c6c (patch) | |
tree | 95f88e910ec3388d82c5e3814f0c2cb6f6c4b49c /lib | |
parent | 05280ce5c09fea7f9e9bdddb69e3d21b8debe088 (diff) | |
download | dotfiles-e9f52f24c29f798d618c6e8e68ceabbd86bd0c6c.tar.gz |
hooks!
Diffstat (limited to 'lib')
-rw-r--r-- | lib/funcs.sh | 17 | ||||
-rw-r--r-- | lib/hooks.sh | 18 |
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/funcs.sh b/lib/funcs.sh index 2126e9a..0122c60 100644 --- a/lib/funcs.sh +++ b/lib/funcs.sh @@ -100,17 +100,12 @@ choose_target() { fi } -housekeeping() { - git submodule init - git submodule update - - #.files is used to tell scripts where to look for the dotfiles - [ -f "$HOME/.files" ] && source "$HOME/.files" - if [ "$DOTFILEBASE" != "$(pwd)" ] && yes_no "'.files' out of date. Regenerate?"; then - echo "DOTFILEBASE=\"$(pwd)\"" > $HOME/.files +debug() { + if [ "$DEBUG" = "yes" ]; then + echo "[DEBUG] $@" fi +} - if [ ! -f "$HOME/.files.config" ] && yes_no ".files.config does not exist. Populate with defaults?"; then - cp "config.default" "$HOME/.files.config" - fi +warning() { + echo "[WARNING] $@" } diff --git a/lib/hooks.sh b/lib/hooks.sh new file mode 100644 index 0000000..8d5fc1d --- /dev/null +++ b/lib/hooks.sh @@ -0,0 +1,18 @@ +# Functions for hooks + +# 1: Name of hook +call_hook() { + if [ ! -x "hooks/$1.hook" ]; then + debug "$1.hook was not found. Skipping." + return + fi + + debug "Running hook $1" + + hooks/$1.hook 2>&1 | (while read line; do echo [hook: $1] $line; done) + RET=${PIPESTATUS[0]} + + if [ $RET -ne 0 ]; then + warning "Hook $1 exitet with code $RET" + fi +} |