-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·117 lines (102 loc) · 2.76 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
rootd=${HOME}/.${USER}
cwd=${PWD}
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
if [ -d $rootd ]
then
cd $rootd
echo "update install env..."
git pull -r
else
git clone https://github.com/journeylee/private-scripts.git $rootd
fi
if [ ! -d "${HOME}/.oh-my-zsh" ]
then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh \
| sed -e '/env zsh/d')"
fi
function backup {
# Use colors, but only if connected to a terminal, and that terminal
# supports them.
if which tput >/dev/null 2>&1; then
ncolors=$(tput colors)
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
else
RED=""
GREEN=""
YELLOW=""
BLUE=""
BOLD=""
NORMAL=""
fi
[ "x$1" != "x" ] && [ -e $1 ] && \
printf "${BOLD}${YELLOW}$1${NORMAL} exists, backup to ${YELLOW}${BOLD}$1.bak.`date +%Y-%m-%dT%H.%M.%S`${NORMAL}...\n" && \
mv $1 $1.bak.`date +%Y-%m-%dT%H.%M.%S`
}
backup ${HOME}/.vimrc
ln -snf ${rootd}/vimrc ${HOME}/.vimrc
backup ${HOME}/.vim
ln -snf ${rootd}/vim ${HOME}/.vim
backup ${HOME}/.bashrc
ln -snf ${rootd}/bashrc ${HOME}/.bashrc
backup ${HOME}/.bash_profile
ln -snf ${rootd}/bash_profile ${HOME}/.bash_profile
ln -snf ${rootd}/ohmyzsh/custom/themes ${HOME}/.oh-my-zsh/custom/
case `uname -s` in
"Darwin" )
temp=`mktemp -t jpsi` || (
echo "Error: cant make temp file." >&2
exit 2
)
;;
"Linux" )
temp=`mktemp -t jpsi.XXXXXX` || (
echo "Error: cant make temp file." >&2
exit 2
)
;;
*)
echo "Error: unsupported OS, only OS X and Linux supported currently."
;;
esac
sed -e 's@ZSH_THEME="[^"]\{1,\}"@ZSH_THEME="ys.custom"@g' \
-e 's@plugins=([^)]\{1,\})@plugins=(git bundler encode64 jsontools redis-cli sudo tmux urltools web-search)@g' \
${HOME}/.zshrc > $temp
if [[ `uname -s` == "Darwin" ]]
then
echo "plugins+=(osx brew)" >> $temp
fi
cat >> $temp <<EOF
export HOMEBREW_GITHUB_API_TOKEN="f1b82f8b4605730becfb6eaf27837ffeb6887f82"
export GOPATH=\$HOME/Documents/go
export PATH=\$PATH:/usr/local/texlive/2015basic/bin/x86_64-darwin:\$GOPATH/bin
EOF
mv -f $temp ${HOME}/.zshrc
vim +PlugInstall +qall
printf "${BLUE} Please restart your shell or manually execute /bin/zsh to change shell!${NORMAL}\n"