dot/update.sh

32 lines
1 KiB
Bash
Raw Normal View History

2024-06-18 11:40:44 +00:00
#!/bin/bash
#
# minimal dotfile manager
# tracks files / copies them into the repo, sorted by hostname
#
2024-06-18 13:41:09 +00:00
# note: assumes pwd is this repo before running this script
2024-06-18 13:28:13 +00:00
set -u
2024-06-18 11:40:44 +00:00
2024-06-19 12:01:31 +00:00
# array of files/dirs [relative to home] to include
2024-06-18 11:40:44 +00:00
DOTS=(
'.vimrc'
'.config/nvim/init.vim'
'.config/nvim/coc-settings.json'
2024-06-18 13:28:13 +00:00
'.config/autostart-i3ipc.yml'
'.config/sway'
2024-06-18 11:40:44 +00:00
)
2024-06-19 11:23:55 +00:00
# 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"
2024-06-19 12:01:31 +00:00
# ensure the host running this script/updating dotfiles has a directory within the repo
HOST_DIR="${DOT_DIR}/${HOSTNAME}"
[ -d "$HOST_DIR" ] || mkdir -v "$HOST_DIR"
2024-06-18 13:28:13 +00:00
2024-06-19 12:01:31 +00:00
# begin dotfile processing - ensure structure is retained, naively copy w/ rsync. rely on Git to tell us about changes.
2024-06-19 11:23:55 +00:00
# TODO: reconsider, edge cases?
2024-06-18 11:40:44 +00:00
for DOT in "${DOTS[@]}"; do
2024-06-19 12:01:31 +00:00
DEST="${HOST_DIR}/$DOT"
2024-06-19 11:23:55 +00:00
echo "Copying '$HOME/$DOT' to '$DEST'"
rsync -aqv "$HOME/$DOT" "$DEST" || echo "Couldn't copy '$DOT', got rc: $?"
2024-06-18 11:40:44 +00:00
done