-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·302 lines (260 loc) · 10.8 KB
/
install.sh
File metadata and controls
executable file
·302 lines (260 loc) · 10.8 KB
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Install eza from binary
install_eza_linux() {
if command -v eza &> /dev/null; then
return
fi
echo -e "${GREEN}Installing eza...${NC}"
if command -v apt-get &> /dev/null; then
sudo mkdir -p /etc/apt/keyrings
wget -qO- https://raw.githubusercontent.com/eza-community/eza/main/deb.asc | sudo gpg --dearmor -o /etc/apt/keyrings/gierens.gpg
echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" | sudo tee /etc/apt/sources.list.d/gierens.list
sudo apt update
sudo apt install -y eza
elif command -v dnf &> /dev/null; then
sudo dnf install -y eza
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm eza
else
# Fallback to binary download
local eza_arch
case "$(uname -m)" in
x86_64) eza_arch="x86_64-unknown-linux-gnu" ;;
aarch64) eza_arch="aarch64-unknown-linux-gnu" ;;
armv7l) eza_arch="armv7-unknown-linux-gnueabihf" ;;
*) echo -e "${YELLOW}Unsupported architecture for eza: $(uname -m)${NC}"; return ;;
esac
cd /tmp
wget -q "https://github.com/eza-community/eza/releases/latest/download/eza_${eza_arch}.tar.gz"
tar -xzf "eza_${eza_arch}.tar.gz"
sudo mv eza /usr/local/bin/
rm "eza_${eza_arch}.tar.gz"
cd -
fi
}
# Install modern CLI tools on Linux
install_modern_tools_linux() {
echo -e "${GREEN}Installing modern CLI tools...${NC}"
# Try to install from package manager first
if command -v apt-get &> /dev/null; then
sudo apt-get install -y bat ripgrep fd-find fzf lazygit 2>/dev/null || true
# Create bat symlink if batcat exists (Ubuntu/Debian naming)
[[ -x /usr/bin/batcat ]] && sudo ln -sf /usr/bin/batcat /usr/local/bin/bat
# Create fd symlink if fdfind exists (Ubuntu/Debian naming)
[[ -x /usr/bin/fdfind ]] && sudo ln -sf /usr/bin/fdfind /usr/local/bin/fd
elif command -v dnf &> /dev/null; then
sudo dnf install -y bat ripgrep fd-find fzf lazygit 2>/dev/null || true
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm bat ripgrep fd fzf lazygit 2>/dev/null || true
fi
# Install eza from binary
install_eza_linux
# Install delta
install_delta_linux
}
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
else
echo "unknown"
fi
}
# Install packages based on OS
install_packages() {
local os=$(detect_os)
case $os in
"macos")
if ! command -v brew &> /dev/null; then
echo -e "${YELLOW}Installing Homebrew...${NC}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install zsh tmux git vim curl fontconfig git-delta bat ripgrep fd fzf eza coreutils lazygit lazygit
;;
"linux")
if command -v apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install -y zsh tmux git vim curl fontconfig build-essential
# Install modern tools
install_modern_tools_linux
elif command -v dnf &> /dev/null; then
sudo dnf install -y zsh tmux git vim curl fontconfig gcc
install_modern_tools_linux
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm zsh tmux git vim curl fontconfig base-devel
install_modern_tools_linux
else
echo -e "${RED}Unsupported package manager${NC}"
exit 1
fi
;;
*)
echo -e "${RED}Unsupported OS: $OSTYPE${NC}"
exit 1
;;
esac
}
# Install delta on Linux systems
install_delta_linux() {
if command -v delta &> /dev/null; then
return
fi
echo -e "${GREEN}Installing delta...${NC}"
cd /tmp
local arch_pattern
case "$(uname -m)" in
x86_64) arch_pattern="x86_64-unknown-linux-gnu" ;;
aarch64) arch_pattern="aarch64-unknown-linux-gnu" ;;
armv7l) arch_pattern="arm-unknown-linux-gnueabihf" ;;
*) echo -e "${YELLOW}Unsupported architecture: $(uname -m)${NC}"; return ;;
esac
local delta_url=$(curl -s https://api.github.com/repos/dandavison/delta/releases/latest | grep "browser_download_url.*${arch_pattern}.tar.gz" | cut -d '"' -f 4)
if [[ -n "$delta_url" ]]; then
curl -L "$delta_url" -o delta.tar.gz
tar -xzf delta.tar.gz
sudo mv delta-*/delta /usr/local/bin/
rm -rf delta*
else
echo -e "${YELLOW}Could not download delta binary${NC}"
fi
cd -
}
# Create symlinks safely
create_symlink() {
local source="$1"
local target="$2"
if [[ -L "$target" ]]; then
echo -e "${YELLOW}Removing existing symlink: $target${NC}"
rm "$target"
elif [[ -f "$target" ]] || [[ -d "$target" ]]; then
echo -e "${YELLOW}Backing up existing file: $target${NC}"
mv "$target" "${target}.backup.$(date +%Y%m%d_%H%M%S)"
fi
ln -sf "$source" "$target"
echo -e "${GREEN}Created symlink: $target -> $source${NC}"
}
# Install Oh My Zsh and plugins
install_zsh_setup() {
# Install Oh My Zsh if not present
if [[ ! -d ~/.oh-my-zsh ]]; then
echo -e "${GREEN}Installing Oh My Zsh...${NC}"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
# Install zsh-autosuggestions
if [[ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ]]; then
echo -e "${GREEN}Installing zsh-autosuggestions...${NC}"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
# Install zsh-syntax-highlighting
if [[ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ]]; then
echo -e "${GREEN}Installing zsh-syntax-highlighting...${NC}"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
}
# Install vim plugins
install_vim_plugins() {
# Create vim directories
mkdir -p ~/.vim/tmp/backup ~/.vim/tmp/swap ~/.vim/tmp/undo
# Install vim-plug if not present
if [[ ! -f ~/.vim/autoload/plug.vim ]]; then
echo -e "${GREEN}Installing vim-plug...${NC}"
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
# Install plugins
echo -e "${GREEN}Installing vim plugins...${NC}"
vim +PlugInstall +qall
}
# Install Tmux Plugin Manager
install_tmux_plugins() {
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
echo -e "${GREEN}Installing Tmux Plugin Manager...${NC}"
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
echo -e "${YELLOW}After tmux starts, press Ctrl-a + I to install plugins${NC}"
else
echo -e "${YELLOW}TPM already installed${NC}"
fi
echo -e "${GREEN}Tmux Plugin Manager ready!${NC}"
echo -e "${YELLOW}Restart tmux and press Ctrl-a + I to install Catppuccin theme${NC}"
}
# Install and configure Starship
install_starship() {
if ! command -v starship &> /dev/null; then
echo -e "${GREEN}Installing Starship prompt...${NC}"
curl -sS https://starship.rs/install.sh | sh -s -- -y
# Add starship to PATH if needed
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
fi
# Create symlink to the Catppuccin Powerline starship configuration
echo -e "${GREEN}Creating custom starship config...${NC}"
create_symlink "$dotfiles_dir/starship/starship.toml" ~/.config/starship.toml
}
# Setup git configuration
setup_git_config() {
create_symlink "$dotfiles_dir/git/gitconfig" ~/.gitconfig
create_symlink "$dotfiles_dir/git/gitconfig_template" ~/.gitconfig_template
create_symlink "$dotfiles_dir/git/git_template" ~/.git_template
create_symlink "$dotfiles_dir/git/gitconfig_delta" ~/.gitconfig_delta
}
main() {
local dotfiles_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo -e "${GREEN}Installing dotfiles from: $dotfiles_dir${NC}"
# Install packages
echo -e "${GREEN}Installing packages...${NC}"
install_packages
# Install zsh setup
echo -e "${GREEN}Setting up Zsh...${NC}"
install_zsh_setup
# Create necessary directories
mkdir -p ~/.ssh ~/.local/share/konsole ~/.config
# Create symlinks
create_symlink "$dotfiles_dir/bash/bashrc" ~/.bashrc
create_symlink "$dotfiles_dir/bash/profile" ~/.profile
create_symlink "$dotfiles_dir/bash/bash_aliases" ~/.bash_aliases
create_symlink "$dotfiles_dir/bash/bash_colors" ~/.bash_colors
create_symlink "$dotfiles_dir/zsh/zshrc" ~/.zshrc
# Install and configure Starship
install_starship
# Setup git with conditional delta support
setup_git_config
# Create symlinks
create_symlink "$dotfiles_dir/tmux/tmux.conf" ~/.tmux.conf
create_symlink "$dotfiles_dir/ssh/config" ~/.ssh/config
create_symlink "$dotfiles_dir/vim" ~/.vim
create_symlink "$dotfiles_dir/vim/vimrc" ~/.vimrc
create_symlink "$dotfiles_dir/vim/gvimrc" ~/.gvimrc
# Install vim plugins
echo -e "${GREEN}Setting up Vim...${NC}"
install_vim_plugins
# Install tmux plugins
echo -e "${GREEN}Setting up Tmux...${NC}"
install_tmux_plugins
echo -e "${GREEN}Dotfiles installation complete!${NC}"
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Install a Nerd Font from https://www.nerdfonts.com/"
echo "2. Restart your terminal or run: source ~/.zshrc"
echo "3. In tmux, press Ctrl-a + I to install plugins and activate Catppuccin theme"
echo "4. For VS Code: cat $dotfiles_dir/vscode/extensions.txt | xargs -L 1 code --install-extension"
echo ""
echo -e "${GREEN}Modern CLI tools installed:${NC}"
command -v bat &> /dev/null && echo " ✓ bat (better cat) - use: acat"
command -v rg &> /dev/null && echo " ✓ ripgrep (better grep) - use: agrep"
command -v fd &> /dev/null && echo " ✓ fd (better find) - use: afind"
command -v fzf &> /dev/null && echo " ✓ fzf (fuzzy finder)"
command -v eza &> /dev/null && echo " ✓ eza (better ls) - use: al, all, ala, atree"
command -v delta &> /dev/null && echo " ✓ delta (better git diff)"
command -v lazygit &> /dev/null && echo " ✓ lazygit (terminal UI for git)"
echo ""
echo -e "${GREEN}Enjoy your enhanced development environment! 🚀${NC}"
}
main "$@"