box-setup/copy_configs

44 lines
791 B
Plaintext
Raw Normal View History

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