Skip to content

Instantly share code, notes, and snippets.

@sssemil
Last active October 28, 2023 18:03
Show Gist options
  • Save sssemil/c871c4e7eccfd0b689d1cc2c123d2ca2 to your computer and use it in GitHub Desktop.
Save sssemil/c871c4e7eccfd0b689d1cc2c123d2ca2 to your computer and use it in GitHub Desktop.
Basic zsh setup
#!/bin/bash
set -e
# Check if zsh is installed
if ! command -v zsh &> /dev/null; then
echo "zsh is not installed. Please install zsh first."
exit 1
fi
# Install oh-my-zsh
echo "Installing oh-my-zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Wait for the previous process to finish
wait
# Ensure ~/.oh-my-zsh exists before cloning plugins
if [ ! -d "~/.oh-my-zsh" ]; then
echo "~/.oh-my-zsh doesn't exist. Exiting without cloning plugins."
exit 1
fi
# Install zsh-autosuggestions plugin
echo "Installing zsh-autosuggestions plugin..."
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Install zsh-syntax-highlighting plugin
echo "Installing zsh-syntax-highlighting plugin..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# Update plugins in .zshrc
echo "Updating plugins list in .zshrc..."
sed -i.bak '/^plugins=(git)$/a \ \ zsh-syntax-highlighting\n \ zsh-autosuggestions' ~/.zshrc
# Change ZSH_THEME to "agnoster"
echo "Setting ZSH_THEME to 'agnoster'..."
sed -i.bak 's/ZSH_THEME=".*"/ZSH_THEME="agnoster"/' ~/.zshrc
# Print instructions for user
echo "All done! Please start a new terminal session to see the changes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment