Skip to content

Instantly share code, notes, and snippets.

@thiagozs
Created June 27, 2023 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagozs/fa80aa4ce541a07ca11d11d2d8780ff3 to your computer and use it in GitHub Desktop.
Save thiagozs/fa80aa4ce541a07ca11d11d2d8780ff3 to your computer and use it in GitHub Desktop.
Install zsh script
#!/bin/bash
# Update package lists
sudo apt-get update
# Check if Zsh is installed, and if not, install it
if ! command -v zsh &> /dev/null
then
echo "Zsh is not installed. Installing..."
sudo apt-get install -y zsh
else
echo "Zsh is already installed."
fi
# Check if Oh-My-Zsh is installed, and if not, install it
if [ ! -d "$HOME/.oh-my-zsh" ]
then
echo "Oh-My-Zsh is not installed. Installing..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "Oh-My-Zsh is already installed."
fi
# Check if zsh-autosuggestions is installed, and if not, install it
if [ ! -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]
then
echo "zsh-autosuggestions is not installed. Installing..."
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
else
echo "zsh-autosuggestions is already installed."
fi
# Check if zsh-syntax-highlighting is installed, and if not, install it
if [ ! -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]
then
echo "zsh-syntax-highlighting is not installed. Installing..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
else
echo "zsh-syntax-highlighting is already installed."
fi
# Check if the plugins are in the .zshrc file, and if not, add them
if ! grep -q 'plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' ~/.zshrc
then
echo "Adding plugins to .zshrc..."
echo "plugins=(git zsh-autosuggestions zsh-syntax-highlighting)" >> ~/.zshrc
echo "Plugins added."
else
echo "Plugins are already in .zshrc."
fi
# Source .zshrc to apply changes immediately
source ~/.zshrc
echo "Setup complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment