-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-env
More file actions
executable file
·64 lines (52 loc) · 901 Bytes
/
dev-env
File metadata and controls
executable file
·64 lines (52 loc) · 901 Bytes
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
dry="0"
while [[ $# > 0 ]]; do
if [[ $1 == "--dry" ]]; then
dry="1"
fi
shift
done
log(){
if [[ $dry == "1" ]]; then
echo "[DRY_RUN]: $@"
else
echo "$@"
fi
}
execute(){
log "execute $@"
if [[ $dry == "1" ]]; then
return
fi
"$@"
}
log "---------- dev-env -----------"
cd $script_dir
copy_dir(){
from=$1
to=$2
if [ ! -d "$to" ]; then
mkdir $to
fi
pushd $from > /dev/null
dirs=$(find . -mindepth 1 -maxdepth 1 -type d)
for dir in $dirs; do
execute rm -rf $to/$dir
execute cp -r $dir $to/$dir
done
popd > /dev/null
}
copy_file(){
from=$1
to=$2
name=$(basename $from)
execute rm $to/$name
execute cp $from $to/$name
}
copy_dir .config $XDG_CONFIG_HOME
copy_dir .local $HOME/.local
copy_dir .devbox $HOME
copy_file .zshrc $HOME
copy_file .gitconfig $HOME
copy_file .ideavimrc $HOME