blob: 58cad15ae53f032ac04ac0c1f4060cf82a9cf079 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/bin/zsh
set -o shwordsplit
target="$HOME/personal"
log() {
if [[ $dry == "1" ]]; then
echo "[DRY_RUN]: $@"
else
echo "$@"
fi
}
execute() {
log "execute $@"
if [[ $dry == "1" ]]; then
return
fi
"$@"
}
copy_dir() {
from=$1
to=$2
pushd $from
dirs="$(find . -maxdepth 1 -mindepth 1 -type d)"
for dir in $dirs; do
log "Copying $dir"
execute rm -rf $to/$dir
execute cp -r $dir $to/$dir
done
popd
}
copy_file() {
from=$1
to=$2
name=$(basename $from)
execute rm $to/$name
execute cp $from $to/$name
}
|