-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh_old
executable file
·148 lines (121 loc) · 3.21 KB
/
install.sh_old
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
#! /bin/bash
DOT_DIR=$(dirname "$(pwd)/$0")
yes_or_no()
{
while true; do
read -p "$1 ([y]/n)?" -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
return 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
return 1
else
echo "Please entry Y, y or N, n"
fi
done
}
back_or_override()
{
FILE=$1
if [ -e $FILE ]; then
yes_or_no "$FILE file exist, backup it"
if [ $? -eq "0" ]; then
if [ -e $FILE.bk ]; then
yes_or_no "$FILE.bk exist, override it?"
if [ $? -eq "1" ]; then
echo "Can't backup $FILE, abort!"
exit 1
fi
rm -fr $FILE.bk
fi
mv $FILE $FILE.bk
else
rm -fr $FILE
fi
fi
}
zsh()
{
echo "installing zsh config files"
ZSHRC_FILE=$DOT_DIR/oh-my-zsh/zshrc
ZSHTHEME_FILE=$DOT_DIR/oh-my-zsh/oh-my-zsh_themes/d0u9.zsh-theme
TGT_RC_FILE=$HOME/.zshrc
TGT_THEME_FILE=$HOME/.oh-my-zsh/themes/d0u9.zsh-theme
back_or_override $TGT_RC_FILE
ln -s $ZSHRC_FILE $TGT_RC_FILE
rm -fr $TGT_THEME_FILE
ln -s $ZSHTHEME_FILE $TGT_THEME_FILE
echo "install finished, you have to manually execute 'source ~/.zshrc' to active it"
echo "nerd font is needed, you can find it on Github"
}
tmux()
{
echo "installing zsh config files"
TMUX_CONF=$DOT_DIR/tmux/tmux.conf
TMUX_CONF_DIR=$DOT_DIR/tmux
TGT_TMUX_CONF=$HOME/.tmux.conf
TGT_TMUX_CONF_DIR=$HOME/.tmux
back_or_override $TGT_TMUX_CONF
ln -s $TMUX_CONF $TGT_TMUX_CONF
back_or_override $TGT_TMUX_CONF_DIR
ln -s $TMUX_CONF_DIR $TGT_TMUX_CONF_DIR
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo "install finished, you have to manuall execute 'prefix+I' in tmux to install plugins"
}
nvim()
{
echo "installing nvim config files"
mkdir -p $HOME/.config
NVIM_CONF=$DOT_DIR/nvim
TGT_NVIM_CONF=$HOME/.config/nvim
back_or_override $TGT_NVIM_CONF
ln -s $NVIM_CONF $TGT_NVIM_CONF
git clone https://github.com/wbthomason/packer.nvim $DOT_DIR/nvim/runtime/plugins/pack/packer/start/packer.nvim
echo 'install finished, you have to execute `PackerInstall` in nvim to install plugins'
echo 'Run command below to install code highlights'
echo ' :TSInstall bash c cpp comment go html css javascript json json5 lua markdown python ruby rust toml yaml kdl'
}
mutt()
{
ln -s $(pwd)/neomutt $HOME/.mutt
mkdir -p $HOME/.mutt/cache/default/{headers,bodies}
ln -s $HOME/.dot/conf/neomutt/account_default.info $HOME/.mutt
}
zellij()
{
echo "installing zellij config files"
mkdir -p $HOME/.config
ZELLIJ_CONF=$DOT_DIR/zellij
TGT_ZELLIJ_CONF=$HOME/.config/zellij
back_or_override $TGT_ZELLIJ_CONF
ln -s $ZELLIJ_CONF $TGT_ZELLIJ_CONF
}
if ! hash curl 2> /dev/null; then
echo "curl can not be found"
exit 1
fi
case "$1" in
"zsh")
zsh
;;
"tmux")
tmux
;;
"nvim")
nvim
;;
"mutt")
mutt
;;
"zellij")
zellij
;;
*)
echo "install all"
zellij
zsh
tmux
nvim
mutt
;;
esac