-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·146 lines (119 loc) · 4.31 KB
/
init.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
137
138
139
140
141
142
143
144
145
#!/bin/bash +e
# This bash script should be executed with the assumption
# that the provisioned instance has been equipped with all the needed tools
#
# It is so that we can use this together with instances provisioned using Docker
# where which the tooling are installed in a separate layer and cached
#
# Assumptions:
# - Has git installed
# - Has networking tools such as curl, wget, ping, traceroute etc..
#
# Goals:
# - Provisioned all configuration files
DIR_DOTFILE=~/.dotfiles
DIR_HOME=${HOME}
DIR_CONFIG=${DIR_HOME}/.config
# Clone repo
if [ ! -d "${DIR_HOME}/.dotfiles" ]; then
git clone https://github.com/sluongng/dotfiles.git ${DIR_DOTFILE}
else
echo 'Directory .dotfiles already exist, pulling instead of cloning'
git -C ${DIR_HOME}/.dotfiles pull
exit 0
fi
# Backup existing files
if [ -f "${DIR_HOME}/.zshrc" ]; then
cp ${DIR_HOME}/.zshrc ${DIR_HOME}/.zshrc.bak
echo 'Done back up zsh config'
else
echo 'No .zshrc found'
fi
if [ -f "${DIR_HOME}/.vimrc" ]; then
cp ${DIR_HOME}/.vimrc ${DIR_HOME}/.vimrc.bak
echo 'Done back up vim config'
else
echo 'No .vimrc found'
fi
if [ -f "${DIR_HOME}/.ideavimrc" ]; then
cp ${DIR_HOME}/.ideavimrc ${DIR_HOME}/.ideavimrc.bak
echo 'Done back up IntelliJ IDEA Vim config'
else
echo 'No .ideavimrc found'
fi
if [ -f "${DIR_CONFIG}/nvim/init.vim" ]; then
cp ${DIR_CONFIG}/nvim/.luarc.json ${DIR_CONFIG}/nvim/.luarc.json.bak
cp ${DIR_CONFIG}/nvim/init.lua ${DIR_CONFIG}/nvim/init.lua.bak
echo 'Done back up neovim config'
else
echo 'No init.vim(neovim config) found'
fi
if [ -f "${DIR_CONFIG}/libinput-gestures.conf" ]; then
cp ${DIR_CONFIG}/config/libinput-gestures.conf ${DIR_CONFIG}/config/libinput-gestures.conf.bak
echo 'Done back up libinput-gestures config'
else
echo 'No libinput-gestures config found'
fi
if [ -f "${DIR_CONFIG}/alacritty/alacritty.yml" ]; then
cp ${DIR_CONFIG}/alacritty/alacritty.yml ${DIR_CONFIG}/alacritty/alacritty.yml.bak
echo 'Done back up alacritty config'
else
echo 'No alacritty config found'
fi
if [ -f "${DIR_CONFIG}/kitty/kitty.conf" ]; then
cp ${DIR_CONFIG}/kitty/kitty.conf ${DIR_CONFIG}/kitty/kitty.conf.bak
echo 'Done back up kitty config'
else
echo 'No kitty config found'
fi
if [ -f "${DIR_CONFIG}/bat/config" ]; then
cp ${DIR_CONFIG}/bat/config ${DIR_CONFIG}/bat/config.bak
echo 'Done back up bat config'
else
echo 'No bat config found'
fi
if [ -f "${DIR_HOME}/.tmux.conf" ]; then
cp ${DIR_HOME}/.tmux.conf ${DIR_HOME}/.tmux.conf.bak
echo 'Done back up tmux config'
else
echo 'No .tmux.conf(tmux config) found'
fi
# Provisioning directories
mkdir -p ${DIR_CONFIG}/nvim/
mkdir -p ${DIR_CONFIG}/alacritty/
mkdir -p ${DIR_CONFIG}/kitty/
mkdir -p ${DIR_CONFIG}/bat/
# Link all the dotfiles
ln -sfn ${DIR_DOTFILE}/.zshrc ${DIR_HOME}/.zshrc
echo 'Linked .zshrc from dotfiles'
# ln -sfn ${DIR_DOTFILE}/.vimrc ${DIR_HOME}/.vimrc
ln -sfn ${DIR_DOTFILE}/nvim/init.lua ${DIR_CONFIG}/nvim/init.lua
ln -sfn ${DIR_DOTFILE}/nvim/.luarc.json ${DIR_CONFIG}/nvim/.luarc.json
echo 'Linked nvim/init.lua from dotfiles'
ln -sfn ${DIR_DOTFILE}/.ideavimrc ${DIR_HOME}/.ideavimrc
echo 'Linked .ideavimrc from dotfiles'
ln -sfn ${DIR_DOTFILE}/.tmux.conf ${DIR_HOME}/.tmux.conf
echo 'Linked .tmux.conf from dotfiles'
ln -sfn ${DIR_DOTFILE}/config/libinput-gestures.conf ${DIR_CONFIG}/libinput-gestures.conf
echo 'Linked libinput-gestures config from dotfiles'
ln -sfn ${DIR_DOTFILE}/config/alacritty/alacritty.yml ${DIR_CONFIG}/alacritty/alacritty.yml
echo 'Linked alacritty config from dotfiles'
ln -sfn ${DIR_DOTFILE}/config/kitty/kitty.conf ${DIR_CONFIG}/kitty/kitty.conf
ln -sfn ${DIR_DOTFILE}/config/kitty/one-dark.conf ${DIR_CONFIG}/kitty/one-dark.conf
echo 'Linked kitty config from dotfiles'
ln -sfn ${DIR_DOTFILE}/config/bat/config ${DIR_CONFIG}/bat/config
echo 'Linked bat config from dotfiles'
# Install Homebrew and brew packages
# TODO: Detects MacOS
(
# TODO: Check and skip if 'brew' exists
# echo 'Installing Homebrew (requires sudo)'
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# TODO: Check if Brewfile exists
echo 'Installing all MacOS brew packages using Brewfile'
cd ${DIR_DOTFILE}
brew bundle install
)
# TODO: Install oh-my-zsh and fzf
# TODO: What about Ubuntu and apt/snap packages?
# TODO: Install and update neovim + coc.nvim + treesitter plugins/extensions