2025-01-11 22:30:21 -06:00
|
|
|
#!/bin/zsh
|
|
|
|
|
2025-01-18 14:14:54 -06:00
|
|
|
local dry="0"
|
2025-01-11 22:30:21 -06:00
|
|
|
|
|
|
|
execute() {
|
|
|
|
log "execute $@"
|
2025-01-12 14:30:08 -06:00
|
|
|
[[ $dry != "1" ]] && "$@"
|
2025-01-11 22:30:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
log() {
|
2025-01-12 14:30:08 -06:00
|
|
|
[[ $dry != "1" ]] && echo "$@" || echo "[DRY RUN]: $@"
|
2025-01-11 22:30:21 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
while [[ $# > 0 ]]; do
|
2025-01-12 14:30:08 -06:00
|
|
|
[[ $1 == "--dry" ]] && dry="1"
|
2025-01-11 22:30:21 -06:00
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
log "---------------- dotfiles ----------------"
|
|
|
|
|
|
|
|
copy_dir() {
|
2025-01-18 14:14:54 -06:00
|
|
|
local from=$1
|
|
|
|
local to=$2
|
2025-01-11 22:30:21 -06:00
|
|
|
pushd $from > /dev/null
|
2025-01-18 14:14:54 -06:00
|
|
|
local dirs=(`find . -mindepth 1 -maxdepth 1 -type d`)
|
2025-01-11 22:30:21 -06:00
|
|
|
for dir in $dirs; do
|
2025-01-12 14:30:08 -06:00
|
|
|
[[ -d $to/$dir ]] && execute rm -rf $to/$dir
|
2025-01-11 22:30:21 -06:00
|
|
|
execute cp -rp $dir $to/$dir
|
|
|
|
done
|
|
|
|
popd > /dev/null
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_file() {
|
2025-01-18 14:14:54 -06:00
|
|
|
local from=$1
|
|
|
|
local to=$2
|
|
|
|
local filename=$(basename $from)
|
2025-01-12 14:30:08 -06:00
|
|
|
[[ -e $to/$filename ]] && execute rm $to/$filename
|
2025-01-11 22:30:21 -06:00
|
|
|
execute cp -p $from $to/$filename
|
|
|
|
}
|
|
|
|
|
2025-01-15 00:44:24 -06:00
|
|
|
copy_dir src_files/.config $HOME/.config
|
|
|
|
copy_dir src_files/.local $HOME/.local
|
|
|
|
copy_file src_files/.zshrc $HOME
|