update.sh: simplify
This commit is contained in:
parent
1691adc0f9
commit
c60db34e11
1 changed files with 6 additions and 8 deletions
14
update.sh
14
update.sh
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue