update.sh: simplify

This commit is contained in:
Josh Lay 2024-06-19 07:01:31 -05:00
parent 1691adc0f9
commit c60db34e11
No known key found for this signature in database
GPG key ID: 47AA304B2243B579

View file

@ -6,7 +6,7 @@
# note: assumes pwd is this repo before running this script # note: assumes pwd is this repo before running this script
set -u set -u
# array of files [relative to home] to include # array of files/dirs [relative to home] to include
DOTS=( DOTS=(
'.vimrc' '.vimrc'
'.config/nvim/init.vim' '.config/nvim/init.vim'
@ -18,16 +18,14 @@ DOTS=(
# to avoid hacky pwd/dirname stuff w/ $0 [for now?], inline the path to the repo where copies are held # to avoid hacky pwd/dirname stuff w/ $0 [for now?], inline the path to the repo where copies are held
DOT_DIR="${HOME}/git/dot" DOT_DIR="${HOME}/git/dot"
# ensure the host running this script/updating dotfiles has a directory # ensure the host running this script/updating dotfiles has a directory within the repo
# ... then temporarily change into it for working, or exit. HOST_DIR="${DOT_DIR}/${HOSTNAME}"
# if it couldn't be made/entered [for whatever reason], we won't be able to copy. [ -d "$HOST_DIR" ] || mkdir -v "$HOST_DIR"
[ -d "$HOSTNAME" ] || mkdir -v "$HOSTNAME"
# now that the host/working dir is managed, process the dotfiles # begin dotfile processing - ensure structure is retained, naively copy w/ rsync. rely on Git to tell us about changes.
# ensure their directory structure is retained, naively copy w/ rsync - relying on Git to tell us about changes
# TODO: reconsider, edge cases? # TODO: reconsider, edge cases?
for DOT in "${DOTS[@]}"; do for DOT in "${DOTS[@]}"; do
DEST="${DOT_DIR}/${HOSTNAME}/$DOT" DEST="${HOST_DIR}/$DOT"
echo "Copying '$HOME/$DOT' to '$DEST'" echo "Copying '$HOME/$DOT' to '$DEST'"
rsync -aqv "$HOME/$DOT" "$DEST" || echo "Couldn't copy '$DOT', got rc: $?" rsync -aqv "$HOME/$DOT" "$DEST" || echo "Couldn't copy '$DOT', got rc: $?"
done done