-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-dotfiles.sh
executable file
·87 lines (73 loc) · 1.78 KB
/
install-dotfiles.sh
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
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
set -e
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P )"
cd "$SCRIPTPATH"
REPO_PATH="/tmp/dotfiles"
FROM_BASE="$REPO_PATH/dotfiles"
# log
function log() {
color="\033[0;32m" # Green color
echo -e "$color[INFO]\\033[0m $@"
}
function warn() {
color="\033[1;33m" # Yellow color
echo -e "$color[WARN]\\033[0m $@"
}
# clone dotfiles repo
function clone_dotfiles() {
log "cloning dotfiles repo"
[ -d "$REPO_PATH" ] && rm -rf $REPO_PATH
git clone -q --depth=1 https://github.com/prchann/dotfiles.git $REPO_PATH
# cp -r "/data/ide" "$REPO_PATH"
}
# config iterm2
function config_iterm2() {
log "configuring iterm2"
if [ ! -f "$HOME/.iterm2_shell_integration.zsh" ]; then
curl -sL https://iterm2.com/shell_integration/zsh \
-o $HOME/.iterm2_shell_integration.zsh
else
warn "configuring iterm2: skip"
fi
}
function copy_files () {
replace_msg=$( [[ "$REPLACE" = true ]] && echo ' (and replace)' || echo '' )
log "copying files$replace_msg"
for f in "$@"; do
log "* copying $f"
base=$(basename "$f")
dir=$(dirname "$f")
from="$FROM_BASE/$f"
to="$HOME/$dir"
[ "$REPLACE" = false ] && [ -f "$to/$base" ] && warn "* copying $f: skip" && continue
[ -d "$to" ] || mkdir -p "$to"
[ -f "$to/$base" ] && rm "$to/$base"
cp -r "$from" "$to"
done
}
# set REPO_PATH from enviroment variable
if [ "$1" == "" ]; then
clone_dotfiles
else
REPO_PATH="$1"
fi
config_iterm2
files=(
.config/nvim/lua/custom
# .config/nvim/init.vim
# .config/nvim/coc-settings.json
.tmux.conf
# .vimrc
.zshrc
)
REPLACE=true
copy_files "${files[@]}"
files=(
.ssh/config
.gitconfig
)
REPLACE=false
copy_files "${files[@]}"
# config docker
# cp $FROM_BASE/docker/daemon.json /etc/docker/
# sudo systemctl restart docker