-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
96 lines (84 loc) · 1.78 KB
/
deploy.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
88
89
90
91
92
93
94
95
96
#!/bin/bash
# By yongcong.wang @ 27/11/2019
# opts
set -e # err exit
# set -x # cmd trace
# vars
HOME="$(cd ~; pwd)"
BASH_CONF_DIR="${HOME}/.bash"
VIM_CONF_DIR="${HOME}/.vim"
ZSH_CONF_DIR="${HOME}/.zsh"
TMUX_CONF_DIR="${HOME}/.tmux"
COMMAND=$1
# functions
function setup_environment() {
(type curl &> /dev/null)
if [[ $? = 1 ]]; then
sudo apt install curl
fi
}
function setup_bash() {
# clear
if [[ -d ${BASH_CONF_DIR} ]]; then
rm -rf ${BASH_CONF_DIR}
fi
if [[ -f ${HOME}/.bashrc || -L ${HOME}/.bashrc ]]; then
rm -f ${HOME}/.bashrc
fi
# download config
git clone -b bash [email protected]:yongcongwang/dotfiles.git \
${BASH_CONF_DIR}
ln -s ${BASH_CONF_DIR}/bashrc ${HOME}/.bashrc
}
function setup_vim() {
# clear
if [[ -d ${VIM_CONF_DIR} ]]; then
rm -rf ${VIM_CONF_DIR}
fi
if [[ -f ${HOME}/.vimrc || -L ${HOME}/.vimrc ]]; then
rm -f ${HOME}/.vimrc
fi
# download config
git clone -b vim [email protected]:yongcongwang/dotfiles.git \
${VIM_CONF_DIR}
ln -s ${VIM_CONF_DIR}/vimrc ${HOME}/.vimrc
}
function setup_tmux() {
# clear
if [[ -d ${TMUX_CONF_DIR} ]]; then
rm -rf ${TMUX_CONF_DIR}
fi
if [[ -f ${HOME}/.tmux.conf || -L ${HOME}/.tmux.conf ]]; then
rm -f ${HOME}/.tmux.conf
fi
# download config
git clone -b tmux [email protected]:yongcongwang/dotfiles.git \
${TMUX_CONF_DIR}
ln -s ${TMUX_CONF_DIR}/tmux.conf ${HOME}/.tmux.conf
}
function main() {
setup_environment
case ${COMMAND} in
bash)
setup_bash
;;
tmux)
setup_tmux
;;
vim)
setup_vim
;;
all)
setup_bash
setup_tmux
setup_vim
;;
*)
echo "ERROR: Unknown paramemter: ${COMMAND}"
exit 0
;;
esac
echo "Successfully setup ${COMMAND}, enjoy!"
}
# start
main