-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·267 lines (227 loc) · 7.97 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash
set -e
install_homebrew_and_packages() {
install_homebrew() {
if ! command -v brew &> /dev/null; then
echo "Homebrew is not installed. Installing..."
if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
echo "Homebrew installation successful."
else
echo "Error: Homebrew installation failed."
exit 1
fi
fi
}
install_homebrew_packages() {
echo "Installing Homebrew packages..."
if brew bundle --file="$DOTFILES_DIR/Brewfile"; then
echo "Homebrew packages installation complete."
else
echo "Error: Homebrew packages installation failed."
exit 1
fi
}
}
install_zsh_config() {
DOTFILES_DIR="$HOME/Code/development/dotfiles"
ZSH_CONFIG_DIR="$DOTFILES_DIR/zsh"
ensure_zsh_installed() {
echo "Checking if Zsh is installed..."
if command -v zsh &> /dev/null; then
echo "Zsh is already installed."
else
echo "Zsh is not installed. Installing..."
if sudo apt-get install zsh; then
echo "zsh installation successful."
else
echo "Error: Zsh installation failed."
exit 1
fi
fi
}
change_default_shell_as_zsh() {
if [[ "$SHELL" != "/bin/zsh" ]]; then
echo "Setting Zsh as the default shell..."
if chsh -s /bin/zsh; then
echo "zsh installation successful."
else
echo "Error: Setting Zsh as the default shell failed."
exit 1
fi
fi
}
ensure_zsh_config_installed() {
# ~/.zshrc sembolik bağı var mı kontrol et
if [ -L "$HOME/.zshrc" ] || [ -e "$HOME/.zshrc" ]; then
echo ".zshrc symbolic link is already created. Skipping..."
else
echo "Creating symbolic link for .zshrc..."
if ln -s "$ZSH_CONFIG_DIR/.zshrc" "$HOME/.zshrc"; then
echo ".zshrc symbolic link created."
else
echo "Error: Creating symbolic link failed."
exit 1
fi
fi
}
set_default_shell_zsh() {
local user_shell=$(getent passwd $USER | cut -d: -f7)
if [[ "$user_shell" != "/bin/zsh" ]]; then
echo "Setting Zsh as the default shell..."
chsh -s $(command -v zsh) || {
echo "Error: Setting Zsh as the default shell failed."
exit 1
}
echo "Zsh set as the default shell."
fi
}
ensure_zsh_installed
change_default_shell_as_zsh
ensure_zsh_config_installed
set_default_shell_zsh
echo "Zsh configuration installation complete."
}
install_fonts() {
echo "Installing fonts..."
FONT_DIR="$DOTFILES_DIR/fonts"
TARGET_DIR="$HOME/.local/share/fonts/"
# ~/.local/share/ dizininde fonts klasörü yoksa oluştur
if [ ! -d "$HOME/.local/share/fonts" ]; then
echo "Creating directory: $HOME/.local/share/fonts"
mkdir -p "$HOME/.local/share/fonts"
fi
# Her bir font dosyasını kontrol et ve kopyala
for font_file in "$FONT_DIR"/*; do
font_name=$(basename "$font_file")
target_path="$TARGET_DIR$font_name"
if [ -e "$target_path" ]; then
echo "Font '$font_name' is already installed. Skipping..."
else
cp "$font_file" "$TARGET_DIR"
echo "Font '$font_name' installed."
fi
done
# Font cache'ini güncelle
# only show errors
fc-cache -f -v > /dev/null
echo "Font installation complete."
}
install_mpv_config() {
DOTFILES_DIR="$HOME/Code/development/dotfiles"
MPV_CONFIG_DIR="$DOTFILES_DIR/mpv"
TARGET_DIR="$HOME/.config/"
ensure_mpv_installed() {
# Brewfile içinde mpv var mı kontrol et
if brew list | grep -q '^mpv$'; then
echo "mpv is already installed."
else
echo "Installing mpv..."
if brew install mpv; then
echo "mpv installation successful."
else
echo "Error: mpv installation failed."
exit 1
fi
fi
}
ensure_mpv_config_installed() {
# ~/.config/mpv dizini ya da sembolik linki var mı kontrol et
if [ -L "$TARGET_DIR/mpv" ] || [ -e "$TARGET_DIR/mpv" ]; then
echo "mpv configuration link is already installed. Skipping..."
else
# mpv dizinini ~/.config/ altına sembolik bağ olarak ekle
ln -s "$MPV_CONFIG_DIR" "$TARGET_DIR/mpv"
echo "mpv configuration installed."
fi
echo "mpv configuration installation complete."
}
ensure_mpv_installed
ensure_mpv_config_installed
}
install_tmux_config() {
ensure_tmux_installed() {
# Brewfile içinde tmux var mı kontrol et
if brew list | grep -q '^tmux$'; then
echo "tmux is already installed."
else
echo "Installing tmux..."
if brew install tmux; then
echo "tmux installation successful."
else
echo "Error: tmux installation failed."
exit 1
fi
fi
}
ensure_oh_my_tmux_installed() {
OH_MY_TMUX_DIR="$HOME/.tmux"
# oh-my-tmux dizini var mı kontrol et
if [ -d "$OH_MY_TMUX_DIR" ]; then
echo "oh-my-tmux is already installed."
else
echo "Installing oh-my-tmux..."
git clone https://github.com/gpakosz/.tmux.git "$OH_MY_TMUX_DIR"
ln -s -f "$OH_MY_TMUX_DIR/.tmux.conf" "$HOME/.tmux.conf"
cp "$OH_MY_TMUX_DIR/.tmux.conf.local" "$HOME/"
echo "oh-my-tmux installation successful."
fi
}
ensure_tmux_config_installed() {
TMUX_CONFIG_FILE="$DOTFILES_DIR/tmux/.tmux.conf.local"
TARGET_FILE="$HOME/.tmux.conf.local"
# ~/.tmux.conf.local dosyası ya da sembolik linki var mı kontrol et
if [ -L "$TARGET_FILE" ] || [ -e "$TARGET_FILE" ]; then
echo "tmux configuration link is already installed. Skipping..."
else
# tmux konfigürasyon dosyasını ~/.tmux.conf.local altına sembolik bağ olarak ekle
ln -s "$TMUX_CONFIG_FILE" "$TARGET_FILE"
echo "tmux configuration installed."
fi
echo "tmux configuration installation complete."
}
ensure_tmux_installed
ensure_oh_my_tmux_installed
ensure_tmux_config_installed
echo "tmux configuration installation complete."
}
install_nvim_config() {
ensure_nvim_installed() {
if brew list | grep -q '^neovim$'; then
echo "neovim is already installed."
else
echo "Installing neovim..."
if brew install neovim --HEAD; then
echo "neovim installation successful."
else
echo "Error: neovim installation failed."
exit 1
fi
fi
}
ensure_nvim_config_installed() {
NVIM_CONFIG_DIR="$DOTFILES_DIR/nvim"
TARGET_DIR="$HOME/.config/nvim"
# ~/.config/nvim dizini ya da sembolik linki var mı kontrol et
if [ -L "$TARGET_DIR" ] || [ -e "$TARGET_DIR" ]; then
echo "neovim configuration link is already installed. Skipping..."
else
# neovim konfigürasyon dosyasını ~/.config/nvim altına sembolik bağ olarak ekle
ln -s "$NVIM_CONFIG_DIR" "$TARGET_DIR"
echo "neovim configuration installed."
fi
}
ensure_nvim_installed
ensure_nvim_config_installed
echo "neovim configuration installation complete."
}
main() {
DOTFILES_DIR="$HOME/Code/development/dotfiles"
# install_homebrew_and_packages
install_zsh_config
# install_fonts
# install_mpv_config
# install_tmux_config
# install_nvim_config
echo "Dotfiles installation complete."
}
main