-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-env
More file actions
executable file
·79 lines (66 loc) · 1.46 KB
/
Copy pathdev-env
File metadata and controls
executable file
·79 lines (66 loc) · 1.46 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
if [ -z "$XDG_CONFIG_HOME" ]; then
echo "no xdg config home"
echo "using ~/.config"
XDG_CONFIG_HOME=$HOME/.config
fi
if [ -z "$DEV_ENV" ]; then
echo "env var DEV_ENV needs to be present"
exit 1
fi
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
dry="0"
while [[ $# > 0 ]]; do
if [[ $1 == "--dry" ]]; then
dry="1"
else
filter="$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 "------------------- devenv ---------------------"
copy_dir() {
from=$1
to=$2
pushd $from > /dev/null
dirs=$(find . -mindepth 1 -maxdepth 1 -type d)
for dir in $dirs; do
# Skip the git folder
if [[ $(basename $dir) == ".git" ]]; then
continue
fi
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 -r $from $to/$name
}
log "dev env: "$DEV_ENV
copy_dir .config $XDG_CONFIG_HOME
copy_dir .local $HOME/.local
copy_file $DEV_ENV/.local/scripts/tmux-sessionizer $HOME/.local/scripts
copy_file $DEV_ENV/.zshrc $HOME
copy_file $DEV_ENV/.zsh_profile $HOME
copy_file $DEV_ENV/.gitconfig $HOME
copy_file $DEV_ENV/dev-env $HOME/.local/scripts
hyprctl reload