From the work dotfiles, add this to dotfiles/bin/dotfiles-sync
#!/usr/bin/zsh
# Ensure that local dotfiles have not been modified and synchronize them with
# the remote git repo
local error=false
if [[ ! -z $(git -C $DOTFILES status --porcelain) ]]; then
echo "\033[0;31mError\033[0m: dotfiles has uncommited files"
error=true
fi
local branch=$(git -C $DOTFILES rev-parse --abbrev-ref HEAD)
if [[ "$branch" != "$HOST_SHORT" ]]; then
echo "\033[0;33mWarning\033[0m: dotfiles is not on the correct branch. ('$branch')"
git -C $DOTFILES checkout $HOST_SHORT
fi
if [[ "$error" = false ]]; then
echo "Syncing main dotfiles..."
git -C $DOTFILES pull -r
git -C $DOTFILES push
sh $DOTFILES/install
echo "...done"
fi
make sure to chmod +x bin/dotfiles-sync to make it executable, and make sure that the dotfiles bin directory is on the path
From the work dotfiles, add this to dotfiles/bin/dotfiles-sync
make sure to
chmod +x bin/dotfiles-sync
to make it executable, and make sure that the dotfiles bin directory is on the path