Created
August 4, 2024 00:33
-
-
Save sh1dow3r/21721d058de1bf499c632eb5c4abe1b6 to your computer and use it in GitHub Desktop.
Setting up a new installation on debain-based os
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Colors for log messages | |
GREEN='\033[0;32m' | |
RED='\033[0;31m' | |
NC='\033[0m' # No Color | |
log_success() { | |
echo -e "${GREEN}[SUCCESS]${NC} $1" | |
} | |
log_error() { | |
echo -e "${RED}[ERROR]${NC} $1" >&2 | |
} | |
backup_zshrc() { | |
if [[ -f "$HOME/.zshrc" ]]; then | |
cp "$HOME/.zshrc" "$HOME/.zshrc.backup" && log_success ".zshrc backed up to .zshrc.backup" | |
fi | |
} | |
update_system() { | |
echo "Updating and upgrading system..." | |
sudo apt update && sudo apt upgrade -y && log_success "System updated and upgraded" || log_error "System update/upgrade failed" | |
} | |
install_essential_packages() { | |
echo "Installing essential packages..." | |
sudo apt install -y build-essential curl file git && log_success "Essential packages installed" || log_error "Essential packages installation failed" | |
} | |
install_zsh() { | |
echo "Installing zsh..." | |
sudo apt install -y zsh && log_success "zsh installed" || log_error "zsh installation failed" | |
} | |
install_oh_my_zsh() { | |
echo "Installing Oh My Zsh..." | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && log_success "Oh My Zsh installed" || log_error "Oh My Zsh installation failed" | |
} | |
install_powerlevel10k() { | |
echo "Installing Powerlevel10k theme..." | |
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k && log_success "Powerlevel10k theme installed" || log_error "Powerlevel10k theme installation failed" | |
} | |
configure_zsh_theme() { | |
if ! grep -q "powerlevel10k/powerlevel10k" ~/.zshrc; then | |
echo "Configuring zsh to use Powerlevel10k theme..." | |
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc && log_success "zsh configured to use Powerlevel10k theme" || log_error "zsh configuration failed" | |
else | |
log_success "Powerlevel10k theme already configured in zsh" | |
fi | |
} | |
install_additional_tools() { | |
echo "Installing additional tools (htop, wget, curl, fd)..." | |
sudo apt install -y htop wget curl fd-find && log_success "Additional tools installed" || log_error "Installation of additional tools failed" | |
} | |
configure_powerlevel10k() { | |
echo "Configuring Powerlevel10k with default settings..." | |
cat <<EOF >>~/.zshrc | |
# To customize prompt, run 'p10k configure' or edit ~/.p10k.zsh. | |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh | |
EOF | |
log_success "Powerlevel10k configuration added to .zshrc" | |
} | |
install_zsh_plugins() { | |
echo "Installing Zsh plugins..." | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
log_success "Zsh plugins installed" | |
echo "Configuring Zsh plugins..." | |
sed -i 's/^plugins=(/plugins=(zsh-syntax-highlighting zsh-autosuggestions /' ~/.zshrc && log_success "Zsh plugins configured" || log_error "Zsh plugin configuration failed" | |
} | |
install_gui_apps() { | |
echo "Installing GUI applications (Google Chrome, Visual Studio Code)..." | |
# Install Google Chrome | |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' | |
sudo apt update && sudo apt install -y google-chrome-stable && log_success "Google Chrome installed" || log_error "Google Chrome installation failed" | |
# Install Visual Studio Code | |
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" | |
sudo apt update && sudo apt install -y code && log_success "Visual Studio Code installed" || log_error "Visual Studio Code installation failed" | |
} | |
configure_git() { | |
read -p "Enter your Git user name: " git_user_name | |
read -p "Enter your Git email: " git_email | |
echo "Configuring Git..." | |
git config --global user.name "$git_user_name" | |
git config --global user.email "$git_email" | |
git config --global core.editor "vim" | |
log_success "Git configured with user name '$git_user_name' and email '$git_email'" | |
} | |
set_default_shell_to_zsh() { | |
if [[ "$SHELL" != "$(which zsh)" ]]; then | |
echo "Setting zsh as the default shell..." | |
chsh -s $(which zsh) && log_success "zsh set as the default shell" || log_error "Failed to set zsh as the default shell" | |
else | |
log_success "zsh is already the default shell" | |
fi | |
} | |
add_common_env_vars() { | |
echo "Adding common environment variables to .zshrc..." | |
cat <<EOF >>~/.zshrc | |
# Common environment variables | |
export PATH="/usr/local/bin:\$PATH" | |
export EDITOR="vim" | |
EOF | |
log_success "Common environment variables added to .zshrc" | |
} | |
post_installation_summary() { | |
echo -e "${GREEN}Installation complete. Summary:${NC}" | |
echo "1. System updated and upgraded" | |
echo "2. Essential packages installed" | |
echo "3. zsh installed and set as default shell" | |
echo "4. Oh My Zsh installed" | |
echo "5. Powerlevel10k theme installed and configured" | |
echo "6. Additional tools installed (htop, wget, curl, fd)" | |
echo "7. Zsh plugins installed and configured" | |
echo "8. GUI applications installed (Google Chrome, Visual Studio Code)" | |
echo "9. Git configured" | |
echo "10. Common environment variables added to .zshrc" | |
echo -e "${GREEN}Please restart your terminal for all changes to take effect.${NC}" | |
} | |
main() { | |
backup_zshrc | |
update_system | |
install_essential_packages | |
install_zsh | |
install_oh_my_zsh | |
install_powerlevel10k | |
configure_zsh_theme | |
configure_powerlevel10k | |
install_additional_tools | |
install_zsh_plugins | |
install_gui_apps | |
configure_git | |
set_default_shell_to_zsh | |
add_common_env_vars | |
post_installation_summary | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment