-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·169 lines (132 loc) · 2.98 KB
/
install
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
###
# Require util shells
###
DOTFILES_CURRENT=`dirname ${0}`
source $DOTFILES_CURRENT/tool/tools.sh
###
# Functions
###
load_colors
###
# Start install
###
printf "${BOLD}${GREEN}"
echo '.----. .----. .---. .----..-..-. .----. .----.'
echo '| {} \/ {} \{_ _} | {_ | || | | {_ { {__ '
echo '| /\ / | | | | | || `--.| {__ .-._} }'
echo '`---- `---- `- `- `- `---- `---- `---- '
echo "(*'-') < Start install the dotfiles"
printf "${NORMAL}"
###
# Check options
###
while getopts u:e: OPT
do
case $OPT in
u) GIT_USER_NAME=$OPTARG
;;
e) GIT_EMAIL_ADDRESS=$OPTARG
;;
:|\?) usage_exit
;;
esac
done
###
# judge OS
###
OS=`judge_os`
if [ ! $? -eq 0 ]; then
exit 1
fi
###
# check zsh installed
###
if ! type zsh > /dev/null 2>&1 ; then
exit "Zsh is not found. You need install zsh..."
fi
###
# Vim Setup
###
printf "${BOLD}${BLUE}Starting Vim setup${NORMAL}\n"
# backup the vim files
backupDotFiles .vimrc
backupDotFiles .vim
# make the vim files
ln -s `pwd`/vim/vimrc ~/.vimrc
ln -s `pwd`/vim/vimfiles ~/.vim
###
# Intelij IdeaVim Setup
###
printf "${BOLD}${BLUE}Starting IdeaVim setup${NORMAL}\n"
# backup the vim files
backupDotFiles .ideavimrc
# make the vim files
cp `pwd`/phpstorm/ideavimrc $HOME/.ideavimrc
###
# Git Setup
###
printf "${BOLD}${BLUE}Starting Git setup${NORMAL}\n"
# backup the git files
backupDotFiles .gitconfig
backupDotFiles .gitignore
# make the git files
cp `pwd`/gitfiles/gitignore $HOME/.gitignore
cp `pwd`/gitfiles/gitconfig $HOME/.gitconfig
# make original gitconfig_local file
if [ ! -e $HOME/.gitconfig_local ]; then
if [ ! -n "$GIT_USER_NAME" ]; then
printf "${YELLOW}Please enter your git name${NORMAL}\n"
printf "${BOLD}${YELLOW}> ${NORMAL}"
read GIT_USER_NAME
else
printf "${YELLOW}Your git name is $GIT_USER_NAME${NORMAL}\n"
fi
if [ ! -n "$GIT_EMAIL_ADDRESS" ]; then
printf "${YELLOW}Please enter your git e-mail address${NORMAL}\n"
printf "${BOLD}${YELLOW}> ${NORMAL}"
read GIT_EMAIL_ADDRESS
else
printf "${YELLOW}Your git e-mail address is $GIT_EMAIL_ADDRESS${NORMAL}\n"
fi
envsubst < `pwd`/gitfiles/gitconfig_local > $HOME/.gitconfig_local
fi
###
# zsh Setup
###
# include alias.zsh
printf "${BOLD}${BLUE}Starting zsh setup${NORMAL}\n"
# backup the zsh files
backupDotFiles .zshrc
backupDotFiles .zshenv
# create symlink
ln -s `pwd`/zsh/zshrc.zsh $HOME/.zshrc
ln -s `pwd`/zsh/zshenv.zsh $HOME/.zshenv
# make PATH file
if [ ! -e $HOME/.zsh_own_config ]; then
cp `pwd`/zsh/zsh_own_config.zsh $HOME/.zsh_own_config
fi
# make alias file
if [ ! -e $HOME/.zsh_alias ]; then
touch $HOME/.zsh_alias
fi
###
# tmux Setup
###
printf "${BOLD}${BLUE}Starting tmux setup${NORMAL}\n"
# backup .tmux.conf
backupDotFiles .tmux.conf
# cp tmux.conf
cp `pwd`/tmux/tmux.conf $HOME/.tmux.conf
###
# OS dependency
###
if [ ${OS} = "Mac" ]; then
`pwd`/init/macos.sh
fi
###
# Exit
###
printf "${BOLD}${BLUE}Installation is completed${NORMAL}\n"
env zsh
exit 0