-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·92 lines (78 loc) · 2.44 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
if [ $# != 2 ]; then
echo 'Usage:'
echo ''
echo 'install.sh shell domain'
echo ''
echo 'shell: could be bash or zsh.'
echo ''
echo 'domain: could be goron, gerudo, rito or zora.'
exit;
fi
SHELL=$1
DOMAIN=$2
if [ $SHELL = "bash" ]; then
RC="$HOME/.bashrc"
SHELL_ENV='"$BASH_IT"'
elif [ $SHELL = "zsh" ]; then
RC="$HOME/.zshrc"
SHELL_ENV='$ZSH'
fi
if [ $(uname) = "Darwin" ]; then
NEW_LINE=$'\n'
elif [ $(uname) = "Linux" ]; then
NEW_LINE='n'
fi
PWD=`pwd`
# Some clean-up ahead.
sed -i -e "/MY_SH/d" $RC
sed -i -e "/my-sh.sh/d" $RC
## Set My-SH envs.
sed -i -e "s,source $SHELL_ENV,export MY_SH_HOME=$PWD\\${NEW_LINE}export MY_SH_SHELL=$SHELL\\${NEW_LINE}export MY_SH_DOMAIN=$DOMAIN\\${NEW_LINE}source $SHELL_ENV," $RC
# Source my-sh.sh which has prerequisites of shell plugins defined in domain.
sed -i -e "s,source $SHELL_ENV,source $PWD/my-sh.sh\\${NEW_LINE}source $SHELL_ENV," $RC
# Alacritty conf.
if [ $(uname) = "Darwin" ]; then
ALACRITTY_OS_YML='alacritty.darwin.toml'
elif [ $(uname) = "Linux" ]; then
ALACRITTY_OS_YML='alacritty.linux.toml'
fi
ln -sf $PWD/alacritty/$ALACRITTY_OS_YML $HOME/.alacritty.os.toml
ln -sf $PWD/alacritty/alacritty.toml $HOME/.alacritty.toml
# Input rc.
ln -sf $PWD/input/inputrc $HOME/.inputrc
# Vim rc.
ln -sf $PWD/vim/vimrc $HOME/.vimrc
ln -sf $PWD/vim/vimrc $HOME/.ideavimrc
ln -sf $PWD/vim/vimrc $HOME/.vrapperrc
# Tmux conf.
ln -sf $PWD/tmux/tmux.conf $HOME/.tmux.conf
# SSH conf.
ln -sf $PWD/ssh/$DOMAIN/config $HOME/.ssh/config
# Conda conf.
ln -sf $PWD/conda/condarc $HOME/.condarc
# Link shell plugins.
if [ $SHELL = "bash" ]; then
for f in `ls bash-it/common`; do
ln -sf $PWD/bash-it/common/$f $BASH_IT/custom/$f
done
for f in `ls bash-it/$DOMAIN`; do
ln -sf $PWD/bash-it/$DOMAIN/$f $BASH_IT/custom/$f
done
elif [ $SHELL = "zsh" ]; then
rm -rf $HOME/.oh-my-zsh/custom/plugins/common
ln -sf $PWD/oh-my-zsh/common $HOME/.oh-my-zsh/custom/plugins/common
rm -rf $HOME/.oh-my-zsh/custom/plugins/$DOMAIN
ln -sf $PWD/oh-my-zsh/$DOMAIN $HOME/.oh-my-zsh/custom/plugins/$DOMAIN
fi
# Set theme.
if [ $SHELL = "bash" ]; then
echo 'Please set bash-it theme manually.'
elif [ $SHELL = "zsh" ]; then
sed -i -e "s,ZSH_THEME=\".*\",ZSH_THEME=\"random\"," $RC
fi
# Enable plugins.
if [ $SHELL = "bash" ]; then
echo 'Please enable bash-it plugin manually.'
elif [ $SHELL = "zsh" ]; then
sed -i -e "s,plugins=(.*),plugins=(aliases brew docker docker-compose git golang mvn common $DOMAIN)," $RC
fi