Created
March 27, 2026 05:28
-
-
Save melon-husk/b2b98d3469165bc17affebba76d0ecac to your computer and use it in GitHub Desktop.
A bash script that automates the installation of Zsh, Oh My Zsh, and the zsh-autosuggestions plugin for Ubuntu
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 | |
| # Exit immediately if a command exits with a non-zero status | |
| set -e | |
| echo "Updating package list and installing prerequisites..." | |
| sudo apt update | |
| sudo apt install -y zsh git curl | |
| echo "Changing default shell to Zsh for user $USER..." | |
| sudo chsh -s $(which zsh) $USER | |
| echo "Installing Oh My Zsh..." | |
| if [ ! -d "$HOME/.oh-my-zsh" ]; then | |
| # Unattended install prevents dropping into a zsh prompt mid-script | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
| else | |
| echo "Oh My Zsh is already installed." | |
| fi | |
| echo "Installing zsh-autosuggestions plugin..." | |
| ZSH_CUSTOM="$HOME/.oh-my-zsh/custom" | |
| if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then | |
| git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions | |
| else | |
| echo "zsh-autosuggestions is already installed." | |
| fi | |
| echo "Enabling zsh-autosuggestions in ~/.zshrc..." | |
| # This finds the default plugins=(git) line and appends the new plugin | |
| sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions)/g' ~/.zshrc | |
| echo "Setup complete! Please log out and log back in, or run 'exec zsh' to start using your new environment." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment