56 lines
904 B
Bash
Executable File
56 lines
904 B
Bash
Executable File
#!/bin/zsh
|
|
|
|
dry="0"
|
|
|
|
execute() {
|
|
log "execute $@"
|
|
if [[ $dry != "1" ]]; then
|
|
"$@"
|
|
fi
|
|
}
|
|
|
|
log() {
|
|
if [[ $dry != "1" ]]; then
|
|
echo "$@"
|
|
else
|
|
echo "[DRY RUN]: $@"
|
|
fi
|
|
}
|
|
|
|
while [[ $# > 0 ]]; do
|
|
if [[ $1 == "--dry" ]]; then
|
|
dry="1"
|
|
fi
|
|
shift
|
|
done
|
|
|
|
log "---------------- dotfiles ----------------"
|
|
|
|
copy_dir() {
|
|
from=$1
|
|
to=$2
|
|
pushd $from > /dev/null
|
|
dirs=(`find . -mindepth 1 -maxdepth 1 -type d`)
|
|
echo $dirs
|
|
for dir in $dirs; do
|
|
if [[ -d $to/$dir ]]; then
|
|
execute rm -rf $to/$dir
|
|
fi
|
|
execute cp -rp $dir $to/$dir
|
|
done
|
|
popd > /dev/null
|
|
}
|
|
|
|
copy_file() {
|
|
from=$1
|
|
to=$2
|
|
filename=$(basename $from)
|
|
if [[ -e $to/$filename ]]; then
|
|
execute rm $to/$filename
|
|
fi
|
|
execute cp -p $from $to/$filename
|
|
}
|
|
|
|
copy_dir .config $HOME/.config
|
|
# copy_file .zxcv $HOME
|