Skip to content

Instantly share code, notes, and snippets.

@fqdeng
Created July 24, 2024 14:59
Show Gist options
  • Save fqdeng/2fe44d5f395da32f96ceb443b2c5ddc8 to your computer and use it in GitHub Desktop.
Save fqdeng/2fe44d5f395da32f96ceb443b2c5ddc8 to your computer and use it in GitHub Desktop.
auto_install.sh
#!/bin/bash
export ZSH_CUSTOM=$HOME/.oh-my-zsh
# Check if Git is installed
if ! command -v git &> /dev/null; then
echo "Git is not installed. Installing Git..."
# Install Git (You may need to adjust this based on your package manager)
sudo apt-get install git # For Debian/Ubuntu
# or
# sudo yum install git # For CentOS/Fedora
fi
# Check if Zsh is installed
if ! command -v zsh &> /dev/null; then
echo "Zsh is not installed. Installing Zsh..."
# Install Zsh (You may need to adjust this based on your package manager)
sudo apt-get install zsh # For Debian/Ubuntu
# or
# sudo yum install zsh # For CentOS/Fedora
fi
# Install Oh My Zsh (if not already installed)
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# Install zsh-autosuggestions (if not already installed)
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
echo "Installing zsh-autosuggestions..."
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
fi
# Install zsh-syntax-highlighting (if not already installed)
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]; then
echo "Installing zsh-syntax-highlighting..."
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
fi
# Update .zshrc to enable plugins and change theme to "ys"
echo "Enabling plugins and changing theme in .zshrc..."
sed -i 's/plugins=(/plugins=(zsh-autosuggestions zsh-syntax-highlighting /' $HOME/.zshrc
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="ys"/' $HOME/.zshrc
# Append additional configuration to .zshrc
echo "Appending additional configuration to .zshrc..."
cat <<EOL >> $HOME/.zshrc
# Custom Key Bindings
bindkey '^[' backward-word
bindkey '^]' forward-word
# Custom Aliases
alias gs='git status'
EOL
echo "Git, Zsh, Oh My Zsh, zsh-autosuggestions, zsh-syntax-highlighting, and theme change to 'ys' installation complete. Please restart your terminal."
echo "Apply setting."
echo "Install pbcopy"
curl https://raw.githubusercontent.com/skaji/remote-pbcopy-iterm2/master/pbcopy > /usr/bin/pbcopy && sudo chmod +x /usr/bin/pbcopy
echo "pbcopy done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment