forked from shiftc/misc_config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·136 lines (114 loc) · 3.84 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
####install some packages required##########
#fzf
#sudo apt-get install fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
#ctags
sudo apt-get install universal-ctags
#tmux
#vim
#zsh
sudo apt-get install zsh
#ag
sudo apt install silversearcher-ag
#ripgrep
sudo apt-get install ripgrep
#################
#git clone https://github.com/vim/vim.git
#cd vim
#git checkout -b v8-1453 v8.0.1453
#./configure --with-features=huge --enable-multibyte \
#--enable-rubyinterp=yes --enable-pythoninterp=yes --enable-python3interp=yes \
# --with-python3-config-dir=/usr/lib/python3.5/config --enable-perlinterp=yes \
# --enable-luainterp=yes --enable-gui=gtk2 --enable-cscope --prefix=/usr \
# --enable-fail-if-missing
#make VIMRUNTIMEDIR=/usr/share/vim/vim80
#sudo make install
CURRENT_DIR=`pwd`
# Red bold error
function error() {
echo
echo "$fg_bold[red]Error: $* $reset_color"
echo
}
# Green bold message
function message() {
echo
echo "$fg_bold[green]Message: $* $reset_color"
echo
}
lnif() {
if [ -e "$1" ]; then
ln -sf "$1" "$2"
fi
}
CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l)
if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then
error "Zsh is not installed! Please install zsh first!"
exit
fi
unset CHECK_ZSH_INSTALLED
if [ ! -n "$ZSH" ]; then
ZSH=~/.oh-my-zsh
fi
if [ -d "$ZSH" ]; then
message "You already have Oh My Zsh installed."
message "You'll need to remove $ZSH if you want to re-install."
else
message "no oh_my_zsh found, install it"
git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH
# Source ~/.zshrc because we need oh-my-zsh variables
lnif $ZSH/templates/zshrc.zsh-template ~/.zshrc
source ~/.zshrc
# apply patches needed
cd $ZSH
git am $CURRENT_DIR/omz_patches/0001-custom-zshrc.patch
git am $CURRENT_DIR/omz_patches/0001-disable-auto-title-change.patch
#git am $CURRENT_DIR/omz_patches/0001-hack-for-prompt-show-down-due-to-git-status-stuff.patch
#git am $CURRENT_DIR/omz_patches/0002-add-my-OMZ-theme.patch
#git am $CURRENT_DIR/omz_patches/0003-Do-not-use-less-to-show-git-log-message.patch
# If folder isn't exist, then make it
[ -d $ZSH_CUSTOM/plugins ] || mkdir $ZSH_CUSTOM/plugins
# clone plugins needed
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# If this user's login shell is not already "zsh", attempt to switch.
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
# If this platform provides a "chsh" command (not Cygwin), do it, man!
if hash chsh >/dev/null 2>&1; then
message "Time to change your default shell to zsh!"
chsh -s $(grep /zsh$ /etc/shells | tail -1)
# Else, suggest the user do so manually.
else
message "I can't change your shell automatically because this system does not have chsh."
message "Please manually change your default shell to zsh!"
fi
fi
fi
# use symblink for all configs
MYBASH_RC="$HOME/.bashrc"
#MYZSH_RC="$HOME/.zshrc"
MYTIG_RC="$HOME/.tigrc"
MYTIG_THEME="$HOME/.tigrc.theme"
MYTMUX_CONF="$HOME/.tmux.conf"
MYGIT_CONF="$HOME/.gitconfig"
#lnif $CURRENT_DIR/bashrc $MYBASH_RC
#cat $CURRENT_DIR/zshrc >> $MYZSH_RC
lnif $CURRENT_DIR/tigrc $MYTIG_RC
lnif $CURRENT_DIR/tigrc.theme $MYTIG_THEME
lnif $CURRENT_DIR/tmux.conf $MYTMUX_CONF
lnif $CURRENT_DIR/gitconfig $MYGIT_CONF
MYVIM_DIR="$CURRENT_DIR/vim_config"
if [ -d $MYVIM_DIR ]; then
message "vim config exists"
else
message "no vim configs, clone it"
git clone https://github.com/andytian1991/space-vim.git $MYVIM_DIR
fi
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
message "update vimrc/bundle"
cd $MYVIM_DIR
sh -c ./install.sh
message "Done! Please reload your terminal."