From 975b347b7206a0e9caeeea8349e4765b4db654f9 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Fri, 16 Aug 2013 15:42:56 +0200 Subject: Pre-up, post-up, pre-down, and post-down hooks These are programs that, if they exist, will run before or after the syncronization/removal is run. Three use cases caused this: 1. The thoughtbot dotfiles will run a vundle installation set of commands after intitial synchronization. 2. I changed the location of `.bash_history` to `.bash/history` and wanted to move `.bash_history` to `.bash/history` after up to preserve existing history. 3. Moving from an existing old-style custom install script to `rcup` might require some cleanup; this happened in practice, and required a simple script. --- share/rcm.sh.in | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'share/rcm.sh.in') diff --git a/share/rcm.sh.in b/share/rcm.sh.in index ea35e47..36b6762 100644 --- a/share/rcm.sh.in +++ b/share/rcm.sh.in @@ -99,3 +99,18 @@ handle_metadata_flags() { $DEBUG "TAGS: $TAGS" $DEBUG "DOTFILES_DIRS: $DOTFILES_DIRS" } + +run_hooks() { + $DEBUG "run_hooks $1 $2" + $DEBUG " with DOTFILES_DIRS: $DOTFILES_DIRS" + local when=$1 + local direction=$2 + + for dotfiles_dir in $DOTFILES_DIRS; do + $DEBUG "hook: $dotfiles_dir/hooks/$when-$direction" + if [ -x "$dotfiles_dir/hooks/$when-$direction" ]; then + $VERBOSE "running $when-$direction hooks for $dotfiles_dir" + $dotfiles_dir/hooks/$when-$direction + fi + done +} -- cgit v1.2.3