Created
September 18, 2025 01:20
-
-
Save euaaron/793dcc4a7e271e553936473cf2b99b0a to your computer and use it in GitHub Desktop.
A simple bash script to install and configure a few items that I aways use
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
| #!/usr/bin/env bash | |
| # Don't forget to `chmod +x install_softwares.sh` before running this script. | |
| # If not running under bash (e.g., invoked with `sh`), re-exec with bash | |
| if [ -z "${BASH_VERSION:-}" ]; then | |
| exec bash "$0" "$@" | |
| fi | |
| # Author: Aaron Carneiro (https://github.com/euaaron) | |
| # Description: A script to quickly set up Ubuntu with my personal preferences. | |
| set -euo pipefail | |
| title() { | |
| echo "\n============================================================" | |
| echo "$1" | |
| echo "============================================================\n" | |
| } | |
| pause() { | |
| read -rp "Press Enter to return to the menu..." _ | |
| } | |
| option_0_update_prereqs() { | |
| title "Option 0: Update and install prerequisites" | |
| sudo apt update | |
| sudo apt upgrade -y | |
| sudo apt install -y wget gpg curl git gnome-keyring libsecret-1-0 libsecret-1-dev | |
| echo "Prerequisites installed/updated." | |
| } | |
| option_1_install_code_edge() { | |
| title "Option 1: Install VS Code and Microsoft Edge" | |
| # Ensure required tools are present (in case Option 0 wasn't run) | |
| sudo apt update | |
| sudo apt install -y wget gpg curl | |
| # Import Microsoft GPG key and add the VS Code and Edge repositories | |
| # Using a temporary file to avoid leaving artifacts in the working directory. | |
| tmp_gpg="$(mktemp)" | |
| wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > "$tmp_gpg" | |
| sudo install -o root -g root -m 644 "$tmp_gpg" /usr/share/keyrings/microsoft.gpg | |
| rm -f "$tmp_gpg" | |
| echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null | |
| echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/edge stable main" | sudo tee /etc/apt/sources.list.d/microsoft-edge.list >/dev/null | |
| sudo apt update | |
| # Install VS Code and Microsoft Edge | |
| sudo apt install -y code microsoft-edge-stable | |
| # Clean up | |
| sudo apt autoremove -y | |
| echo "Installation of VS Code and Microsoft Edge completed!" | |
| } | |
| option_2_install_zsh_and_theme() { | |
| title "Option 2: Install ZSH, Oh My Zsh, and Spaceship theme" | |
| sudo apt install -y zsh curl git | |
| # Install Oh My Zsh unattended | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
| # Ensure themes directory exists and install/update Spaceship theme | |
| mkdir -p ~/.oh-my-zsh/themes | |
| if [ ! -d ~/.oh-my-zsh/themes/spaceship-prompt ]; then | |
| git clone https://github.com/spaceship-prompt/spaceship-prompt.git ~/.oh-my-zsh/themes/spaceship-prompt | |
| else | |
| git -C ~/.oh-my-zsh/themes/spaceship-prompt pull --ff-only || true | |
| fi | |
| # Create/refresh symlink for the theme | |
| ln -sf ~/.oh-my-zsh/themes/spaceship-prompt/spaceship.zsh-theme ~/.oh-my-zsh/themes/spaceship.zsh-theme | |
| # Switch theme in .zshrc (Oh My Zsh installer typically creates this file) | |
| if [ -f ~/.zshrc ]; then | |
| sed -i 's/ZSH_THEME=".*"/ZSH_THEME="spaceship"/' ~/.zshrc || true | |
| fi | |
| # Change default shell to zsh for the current user (will prompt for password) | |
| if command -v zsh >/dev/null 2>&1; then | |
| chsh -s "$(command -v zsh)" || true | |
| fi | |
| echo "ZSH with Oh My Zsh and Spaceship theme installed! Please restart your terminal." | |
| } | |
| option_3_replace_zshrc() { | |
| title "Option 3: Replace .zshrc with customized version" | |
| # Backup existing .zshrc if present | |
| if [ -f ~/.zshrc ]; then | |
| cp -a ~/.zshrc ~/.zshrc.backup.$(date +%F-%H%M%S) | |
| echo "Backed up existing ~/.zshrc to a timestamped backup." | |
| fi | |
| # Replace .zshrc from GitHub Gist | |
| curl -fsSL https://gist.githubusercontent.com/euaaron/54b5f186bb5b4a19392a4b074947c52c/raw/27e4865c94098a6bfa420a52ca1e835295880c3d/.zshrc -o ~/.zshrc | |
| echo "Downloaded customized ~/.zshrc. Open a new terminal session to load it." | |
| } | |
| show_menu() { | |
| echo | |
| echo "Ubuntu Setup Menu" | |
| echo "----------------------------------------" | |
| echo "0) Update and install prerequisites (run first)" | |
| echo "1) Install VS Code and Microsoft Edge" | |
| echo "2) Install ZSH, Oh My Zsh, and Spaceship theme" | |
| echo "3) Replace .zshrc with my gist version" | |
| echo "a) Run all options" | |
| echo "q) Quit" | |
| echo "----------------------------------------" | |
| } | |
| main() { | |
| while true; do | |
| show_menu | |
| read -rp "Choose an option [0/1/2/3/q]: " choice | |
| case "$choice" in | |
| 0) | |
| option_0_update_prereqs | |
| pause | |
| ;; | |
| 1) | |
| option_1_install_code_edge | |
| pause | |
| ;; | |
| 2) | |
| option_2_install_zsh_and_theme | |
| pause | |
| ;; | |
| 3) | |
| option_3_replace_zshrc | |
| pause | |
| ;; | |
| a|A|all) | |
| option_0_update_prereqs | |
| option_1_install_code_edge | |
| option_2_install_zsh_and_theme | |
| option_3_replace_zshrc | |
| pause | |
| ;; | |
| q|Q|quit|exit) | |
| echo "Goodbye!" | |
| exit 0 | |
| ;; | |
| *) | |
| echo "Invalid selection. Please choose 0, 1, 2, 3, or q to quit." | |
| ;; | |
| esac | |
| done | |
| } | |
| main "$@" | |
| ## Extra Notes | |
| # Install Gnome Extensions and Gnome Tweaks if not already installed: | |
| # sudo apt install gnome-shell-extension-prefs gnome-tweaks | |
| # To add round corners to VS Code Window, install Rounded Window Corners Reborn from: | |
| # https://extensions.gnome.org/extension/7048/rounded-window-corners-reborn/ | |
| # To edit Ubuntu doc style install the extension "User Themes" from: | |
| # https://extensions.gnome.org/extension/19/user-themes/ | |
| # Also edit it in Gnome Tweaks | |
| # To move the window buttons to the left, run: | |
| # gsettings set org.gnome.desktop.wm.preferences button-layout 'close,minimize,maximize' | |
| # To revert to the right, run: | |
| # gsettings set org.gnome.desktop.wm.preferences button-layout ':minimize,maximize,close' | |
| # Add gnome-keyring-daemon --start --components=secrets to .zshrc or .bashrc if you face issues with credential manager in vscode. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment