-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·158 lines (129 loc) · 5.2 KB
/
install.sh
File metadata and controls
executable file
·158 lines (129 loc) · 5.2 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
#!/bin/bash
# ==============================================================================
# AUTOMATED INSTALLATION - 42 ENVIRONMENT
# ==============================================================================
# --- Styling Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# --- Paths ---
DOTFILES_DIR="$HOME/dotfiles"
CONFIG_DIR="$HOME/.config"
BIN_DIR="$HOME/.local/bin"
FONT_DIR="$HOME/.local/share/fonts"
# Add local bins to PATH for the duration of the script
export PATH="$HOME/.cargo/bin:$BIN_DIR:$PATH"
echo -e "${BLUE}🚀 Starting environment installation...${NC}"
# 1. Create base directories
echo -e "${YELLOW}:: Checking directories...${NC}"
mkdir -p "$BIN_DIR"
mkdir -p "$CONFIG_DIR"
mkdir -p "$FONT_DIR"
# 2. RUST Installation (Required for eza, bat, ripgrep, alacritty)
if ! command -v cargo &> /dev/null; then
echo -e "${YELLOW}:: Installing Rust (Cargo)...${NC}"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
else
echo -e "${GREEN}:: Rust is already installed.${NC}"
fi
# 3. Modern tools installation (via Cargo)
install_cargo_tool() {
if ! command -v $1 &> /dev/null; then
echo -e "${YELLOW}:: Installing $1... (May take a while)${NC}"
cargo install $1
else
echo -e "${GREEN}:: $1 is already installed.${NC}"
fi
}
install_cargo_tool "eza" # Replacement for ls
install_cargo_tool "bat" # Replacement for cat
install_cargo_tool "ripgrep" # Replacement for grep
install_cargo_tool "fd-find" # Replacement for find (Required for Telescope)
install_cargo_tool "alacritty" # GPU-accelerated terminal emulator
# Configure Alacritty Desktop Shortcut
if command -v alacritty &> /dev/null; then
echo -e "${YELLOW}:: Creating Desktop shortcut for Alacritty...${NC}"
mkdir -p "$HOME/.local/share/applications"
mkdir -p "$HOME/.local/share/icons"
# 2. Download official icon
if [ ! -f "$HOME/.local/share/icons/Alacritty.svg" ]; then
wget -q -O "$HOME/.local/share/icons/Alacritty.svg" \
"https://raw.githubusercontent.com/alacritty/alacritty/master/extra/logo/alacritty-term.svg"
fi
# 3. Create .desktop file
# Allows GNOME to recognize the application
cat > "$HOME/.local/share/applications/alacritty.desktop" <<EOF
[Desktop Entry]
Type=Application
TryExec=$HOME/.cargo/bin/alacritty
Exec=$HOME/.cargo/bin/alacritty
Icon=$HOME/.local/share/icons/Alacritty.svg
Terminal=false
Categories=System;TerminalEmulator;
Name=Alacritty
GenericName=Terminal
Comment=A fast, cross-platform, OpenGL terminal emulator
StartupNotify=true
EOF
# Set Alacritty as default terminal
gsettings set org.gnome.desktop.default-applications.terminal exec 'alacritty'
gsettings set org.gnome.desktop.default-applications.terminal exec-arg ''
echo -e "${GREEN}:: Alacritty shortcut created and set as default!${NC}"
fi
# 4. Starship Installation (Prompt)
if ! command -v starship &> /dev/null; then
echo -e "${YELLOW}:: Installing Starship...${NC}"
curl -sS https://starship.rs/install.sh | sh -s -- -y --bin-dir "$BIN_DIR"
else
echo -e "${GREEN}:: Starship is already installed.${NC}"
fi
# 5. Nerd Fonts
FONT_NAME="JetBrainsMono"
if [ ! -f "$FONT_DIR/${FONT_NAME}NerdFont-Regular.ttf" ]; then
echo -e "${YELLOW}:: Downloading ${FONT_NAME} Nerd Font...${NC}"
wget -q --show-progress -O "$FONT_DIR/${FONT_NAME}NerdFont-Regular.ttf" \
"https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFont-Regular.ttf"
# Refresh Fonts
echo -e "${YELLOW}:: Updating font cache...${NC}"
fc-cache -f "$FONT_DIR"
else
echo -e "${GREEN}:: Nerd Font already installed.${NC}"
fi
# 6. Symlinks
echo -e "${YELLOW}:: Configuring Dotfiles (Symlinks)...${NC}"
create_link() {
src=$1
dest=$2
# 1. If the destination exists and is a REAL directory (not a link), backup it
if [ -d "$dest" ] && [ ! -L "$dest" ]; then
echo " Backing up existing directory: $dest -> $dest.bak"
mv "$dest" "$dest.bak"
fi
# 2. If the destination exists and is a REAL file (not a link), backup it
if [ -f "$dest" ] && [ ! -L "$dest" ]; then
echo " Backing up existing file: $dest -> $dest.bak"
mv "$dest" "$dest.bak"
fi
# 3. If it's already a symbolic link, remove it first
# (This fixes the infinite loop bug)
if [ -L "$dest" ]; then
rm "$dest"
fi
# 4. Create the new link cleanly
ln -s "$src" "$dest"
echo -e " ${GREEN}OK${NC} $dest"
}
create_link "$DOTFILES_DIR/zshrc" "$HOME/.zshrc"
create_link "$DOTFILES_DIR/starship.toml" "$CONFIG_DIR/starship.toml"
# Alacritty
mkdir -p "$CONFIG_DIR/alacritty"
create_link "$DOTFILES_DIR/alacritty.toml" "$CONFIG_DIR/alacritty/alacritty.toml"
# nvim (Config only, binary must be installed manually or via other means)
create_link "$DOTFILES_DIR/nvim" "$CONFIG_DIR/nvim"
echo -e "${BLUE}===============================================${NC}"
echo -e "${GREEN}✅ Installation successfully completed!${NC}"
echo -e "${BLUE}===============================================${NC}"
echo -e "👉 To finalize: type ${YELLOW}exec zsh${NC} or restart your terminal."