-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
ยท205 lines (174 loc) ยท 7.57 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
ยท205 lines (174 loc) ยท 7.57 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
#!/usr/bin/env zsh
function installDependencies() {
# Check if Oh My Zsh is already installed
if [ -d "${ZSH:-$HOME/.oh-my-zsh}" ]; then
echo "Oh My Zsh already installed. Skipping installation."
else
echo "Installing Oh My Zsh..."
# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended --keep-zshrc
fi
echo "Cloning Oh My Zsh plugins..."
# Clone Oh My Zsh plugins
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
echo "Enabling Corepack and preparing pnpm..."
# Enable Corepack and install pnpm
corepack enable
corepack prepare pnpm@latest --activate
installNerdFonts # Add this call
echo "๐ Dependencies (including optional font) processed."
}
function configureZsh() {
echo "Configuring Zsh..."
echo " Copying .zshrc to ~/.zshrc"
cp ./.zshrc ~/.zshrc
if [ -f "./.p10k.zsh" ]; then
echo " Setting up Powerlevel10k configuration (.p10k.zsh)..."
if [ "$RUNNING_IN_CODESPACES" = "true" ]; then
echo " (Codespaces) Overwriting ~/.p10k.zsh with repository version."
cp ./.p10k.zsh ~/.p10k.zsh
else
if [ -f ~/.p10k.zsh ]; then
echo " Found existing ~/.p10k.zsh."
echo " Backing it up to ~/.p10k.zsh.bak"
cp ~/.p10k.zsh ~/.p10k.zsh.bak
fi
echo " Copying .p10k.zsh to ~/.p10k.zsh"
cp ./.p10k.zsh ~/.p10k.zsh
fi
else
echo " WARNING: .p10k.zsh not found in repository. Skipping Powerlevel10k custom config."
fi
echo "๐ Zsh configured successfully."
}
function configureGit() {
echo "Configuring Git..."
echo " Copying .gitconfig to ~/.gitconfig"
cp ./.gitconfig ~/.gitconfig
echo " Copying .gitignore_global to ~/.gitignore_global"
cp ./.gitignore_global ~/.gitignore_global
echo "๐ Git configured successfully."
}
function configureVim() {
echo "Configuring Vim..."
echo " Copying .vimrc to ~/.vimrc"
cp ./.vimrc ~/.vimrc
echo "๐ Vim configured successfully."
}
function doIt() {
echo "๐ Starting dotfiles setup..."
RUNNING_IN_CODESPACES=${CODESPACES:-false} # Default to false if CODESPACES var isn't set
if [ "$RUNNING_IN_CODESPACES" = "true" ]; then
echo "๐ป Running in GitHub Codespaces environment (non-interactive)."
else
echo "๐ ๏ธ Running in local environment."
fi
if [ "$1" != "-u" ]; then
installDependencies || echo "โ ๏ธ installDependencies failed, continuing..."
fi
configureZsh || echo "โ ๏ธ configureZsh failed, continuing..."
configureGit || echo "โ ๏ธ configureGit failed, continuing..."
configureVim || echo "โ ๏ธ configureVim failed, continuing..."
configureVSCode || echo "โ ๏ธ configureVSCode failed, continuing..."
echo "โ
Done. Restart your terminal or source your ~/.zshrc file."
}
function configureVSCode() {
echo "Configuring VS Code settings..."
if [ ! -d ".vscode" ]; then
echo "๐คท No .vscode directory found in repository. Skipping."
return
fi
if [ "$RUNNING_IN_CODESPACES" = "true" ]; then
echo " (Codespaces) Ensuring ~/.vscode exists and copying repository's .vscode contents."
mkdir -p ~/.vscode
cp -r .vscode/* ~/.vscode/
else
# For local setup, be more careful
if [ ! -d ~/.vscode ]; then
echo " Creating ~/.vscode directory."
mkdir -p ~/.vscode
fi
if [ -f ~/.vscode/settings.json ]; then
echo " Found existing ~/.vscode/settings.json. Skipping copy of settings.json to avoid overwrite."
# Optionally, copy other files from .vscode if they exist and settings.json is the only concern
# For example, copy extensions.json:
if [ -f "./.vscode/extensions.json" ]; then
echo " Copying .vscode/extensions.json to ~/.vscode/extensions.json"
cp ./.vscode/extensions.json ~/.vscode/extensions.json
fi
else
echo " No existing ~/.vscode/settings.json found. Copying repository's .vscode contents."
cp -r .vscode/* ~/.vscode/
fi
fi
echo "๐ VS Code settings processed."
}
trap 'echo "โ An error occurred during setup. Please check the output above." && exit 1' ERR
function installNerdFonts() {
echo "๐ Attempting to install JetBrainsMono Nerd Font..."
# Check for required commands
local missing_commands=()
for cmd in wget unzip fc-cache; do
if ! command -v "$cmd" &> /dev/null; then
missing_commands+=("$cmd")
fi
done
if [ ${#missing_commands[@]} -ne 0 ]; then
echo " โ ๏ธ Missing required commands: ${missing_commands[*]}. Skipping Nerd Font installation."
return 0
fi
# Check OS (rudimentary check for Linux-like systems)
if [[ "$(uname)" != "Linux" ]]; then
echo " โน๏ธ Nerd Font installation script is primarily designed for Linux. Skipping on $(uname)."
return 1 # Or simply return 0 if we don't want to treat non-Linux as an error for the whole script
fi
local font_dir="$HOME/.local/share/fonts"
echo " Creating font directory if it doesn't exist: $font_dir"
mkdir -p "$font_dir"
local font_name="JetBrainsMono"
local zip_file="${font_name}.zip"
local download_url="https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/${zip_file}" # Updated to v3.4.0
# Check if font is already installed using fc-list
echo " Checking if JetBrainsMono Nerd Font is already installed via fc-list..."
if command -v fc-list &>/dev/null; then
if fc-list | grep -q "JetBrainsMono Nerd Font"; then # Case-sensitive grep might be needed depending on fc-list output
echo " โ๏ธ JetBrainsMono Nerd Font already detected by fc-list. Skipping download and installation."
return 0
else
echo " โน๏ธ JetBrainsMono Nerd Font not found by fc-list. Proceeding with installation attempt."
fi
else
echo " โ ๏ธ fc-list command not found. Cannot check if font is already installed via system database. Will proceed with download if files not found locally."
# Fallback to the file-based check if fc-list is not available, but after attempting fc-list.
if [ -f "$font_dir/${font_name}NerdFont-Regular.ttf" ] || [ -f "$font_dir/${font_name} Nerd Font Complete Regular.ttf" ] || [ -f "$font_dir/JetBrains Mono Regular Nerd Font Complete.ttf" ]; then
echo " โ๏ธ JetBrainsMono Nerd Font files found in $font_dir. Skipping download."
echo " Running fc-cache -fv to ensure font cache is up to date."
fc-cache -fv
return 0
fi
fi
echo " Downloading JetBrainsMono Nerd Font from $download_url..."
if wget -P "$font_dir" "$download_url"; then
echo " Download complete. Extracting..."
if unzip -o "$font_dir/$zip_file" -d "$font_dir"; then # -o to overwrite existing files without prompting
echo " Extraction complete."
else
echo " โ Failed to extract font. Please check for errors."
# cleanup zip
rm -f "$font_dir/$zip_file"
return 1
fi
echo " Removing downloaded zip file: $font_dir/$zip_file"
rm -f "$font_dir/$zip_file"
echo " Updating font cache (fc-cache -fv)..."
fc-cache -fv
echo " โ๏ธ JetBrainsMono Nerd Font installed and cache updated successfully."
else
echo " โ Failed to download JetBrainsMono Nerd Font. Skipping."
return 1
fi
}
doIt $1;
unset installDependencies doIt configureZsh configureGit configureVim configureVSCode installNerdFonts;