-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·90 lines (74 loc) · 2.47 KB
/
setup
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
#!/usr/bin/env bash
PLATFORM="unknown"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# Linux
PLATFORM="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
PLATFORM="darwin"
else
echo "Failure, unsupported system"
exit -1
fi
echo "Current platform: ${PLATFORM}"
if [ ! ${HOME} ]; then
echo "Failure, HOME env not set"
exit -1
fi
if [ ! `which curl` ]; then
echo "Failure, No curl, You should install curl first"
exit -1
fi
if [ ! `which zsh` ]; then
echo "Failed to setup zsh env: zsh not installed"
else
# install oh-my-zsh
if [ ! -d ${HOME}/.oh-my-zsh ]; then
echo "oh-my-zsh not installed before, installing......"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
if [ -f ${HOME}/.zshrc ]; then
mv ${HOME}/.zshrc ${HOME}/.zshrc.back
fi
ZSH_SETUP=1
fi
if [ ! `which tmux` ]; then
echo "Failed to setup tmux env: tmux not installed"
else
if [ ! -f ${HOME}/.tmux.conf ]; then
mv ${HOME}/.tmux.conf ${HOME}/.tmux.conf.back
fi
TMUX_SETUP=1
fi
if [ ! `which vim` ]; then
echo "Failed to setup vim env: vim not installed"
else
VIM_SETUP=1
fi
if [[ ! ( $ZSH_SETUP && $TMUX_SETUP && $VIM_SETUP ) ]]; then
echo "Failure: zsh tmux and vim are not installed at all"
exit -1
fi
if [ -d ${HOME}/my-dev-env-conf ]; then
echo "my-dev-env-conf dir exists on home before, back it to my-dev-env-conf.back"
mv ${HOME}/my-dev-env-conf ${HOME}/my-dev-env-conf.back
fi
echo "downloading the my-dev-env-conf......"
git clone --recursive https://github.com/SexyC/my-dev-env-conf.git ${HOME}/my-dev-env-conf
echo "setting zsh..."
cp ${HOME}/my-dev-env-conf/zsh/.zshrc ${HOME}/.zshrc
# set oh-my-zsh path and system path to .zshrc
if [ ${PLATFORM} = 'linux' ]; then
sed -i "s/[[:space:]]*export[[:space:]][[:space:]]*ZSH=.*$/export ZSH=${HOME//\//\\/}\/.oh-my-zsh/g" ${HOME}/.zshrc
sed -i "s/[[:space:]]*export[[:space:]][[:space:]]*PATH=.*$/export PATH=\"${PATH//\//\\/}\"/g" ${HOME}/.zshrc
else
sed -e "s/[[:space:]]*export[[:space:]][[:space:]]*ZSH=.*$/export ZSH=${HOME//\//\\/}\/.oh-my-zsh/g" -i '' ${HOME}/.zshrc
sed -e "s/[[:space:]]*export[[:space:]][[:space:]]*PATH=.*$/export PATH=\"${PATH//\//\\/}\"/g" -i '' ${HOME}/.zshrc
fi
echo "setting zsh done"
echo "setting tmux(${PLATFORM})..."
cp ${HOME}/my-dev-env-conf/tmux/.tmux.conf.${PLATFORM} ${HOME}/.tmux.conf
echo "setting tmux done"
echo "setting vim..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/SexyC/my-vim-conf/master/install)"
echo "setting vim done"