-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
96 lines (81 loc) · 2.57 KB
/
install.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
PRO_NAME='dotfiles'
REQUIRE="git"
SYMLINKS="vimrc screenrc gitconfig bash_profile wgetrc curlrc"
[ -z "$PRO_PATH" ] && PRO_PATH="$HOME/.$PRO_NAME"
[ -z "$REPO_URI" ] && REPO_URI='https://github.com/xw2423/dotfiles.git'
# help functions
msg() {
printf '%b\n' "$1" >&2
}
success() {
msg "\33[32m[O]\33[0m ${1}${2}"
}
error() {
msg "\33[31m[X]\33[0m ${1}${2}"
exit 1
}
warn() {
msg "\33[33m[!]\33[0m ${1}${2}"
}
info() {
msg "\33[32m[>]\33[0m ${1}${2}"
}
lnif() {
if [ ! -e $2 ] ; then
ln -s $1 $2
fi
}
# check if node & npm are installed
for i in $REQUIRE
do
command -v $i >/dev/null && continue || { error "$i command not found. Please Make sure you have $i installed"; }
done
if [ ! -e "$PRO_PATH" ]; then
info "clone $PRO_NAME to $PRO_PATH"
mkdir -p "$PRO_PATH"
git clone -c http.sslversion=tlsv1 "$REPO_URI" "$PRO_PATH"
ret="$?"
success "Successfully cloned $PRO_NAME"
else
info "update $PRO_NAME in $PRO_PATH"
cd "$PRO_PATH" && git pull origin
ret="$?"
success "Successfully updated $PRO_NAME"
fi
#info "backing up current vim config"
#today=`date +%Y%m%d`
#for i in $HOME/.vim $HOME/.vimrc; do [ -e $i ] && [ ! -L $i ] && mv $i $i.$today; done
#for i in $HOME/.vim $HOME/.vimrc; do [ -L $i ] && unlink $i ; done
#success "Successfully backed up your vim configuration"
# install vim-plug
if [ ! -e $PRO_PATH/autoload/plug.vim ]; then
info "Installing Vim-Plug"
curl -fLo "$PRO_PATH/autoload/plug.vim" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
success "Successfully installed vim-plug"
fi
if [[ $OS =~ "Windows" ]]; then
if [ ! -e $HOME/.vim ] ; then
info "run install_windows_link.bat as admin && copy autoload/plug.vim to gvim"
exit
fi
fi
info "setting up symlinks"
lnif $PRO_PATH/ $HOME/.vim
for i in $SYMLINKS
do
lnif $HOME/.vim/$i $HOME/.$i
done
if [[ $OSTYPE =~ "cygwin" ]]; then
lnif $HOME/.vim/minttyrc $HOME/.minttyrc
fi
success "Successfully created symbol links"
[ ! -z $1 ] && exit
info "update/install plugins using vim-plug"
system_shell=$SHELL
export SHELL="/bin/sh"
vim +PlugInstall! +PlugClean +qall
export SHELL=$system_shell
# command -v eslint >/dev/null || warn "eslint is not found from global installation, you may want to run: npm i -g eslint"
# command -v jsctags >/dev/null || warn "for better javascript tags support, it's recommend to install jstags, npm i -g git+https://github.com/ramitos/jsctags.git"
# command -v js-beautify >/dev/null || warn "you may also want to install js-beautify, npm i js-beautify -g"