- Init commit

This commit is contained in:
tuong 2025-07-13 03:36:32 +07:00
commit 6e54551272

View File

@ -0,0 +1,67 @@
#!/usr/bin/env sh
set -e # Exit on error
# Define plugins
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
# Install oh-my-zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "Installing oh-my-zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "oh-my-zsh already installed."
fi
# Install zsh-autosuggestions
if [ ! -d "${ZSH_CUSTOM}/plugins/zsh-autosuggestions" ]; then
echo "Installing zsh-autosuggestions..."
git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM}/plugins/zsh-autosuggestions"
fi
# Install zsh-syntax-highlighting
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
# Install Powerlevel10k theme
if [ ! -d "${ZSH_CUSTOM}/themes/powerlevel10k" ]; then
echo "Installing Powerlevel10k theme..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM}/themes/powerlevel10k"
fi
if [ ! -d "${ZSH_CUSTOM}/plugins/fast-syntax-highlighting" ]; then
echo "Installing fast-syntax-highlighting..."
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting
fi
if [ ! -d "${ZSH_CUSTOM}/plugins/zsh-autocomplete" ]; then
echo "Installing zsh-autocomplete"
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete
fi
ZSHRC="$HOME/.zshrc"
# Modify plugins in .zshrc
echo "Configuring ~/.zshrc..."
# Replace plugins line
if grep -q "^plugins=" "$ZSHRC"; then
sed -i 's/^plugins=.*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting fast-syntax-highlighting zsh-autocomplete)/' "$ZSHRC"
else
echo "plugins=(git zsh-autosuggestions zsh-syntax-highlighting fast-syntax-highlighting zsh-autocomplete)" >> "$ZSHRC"
fi
# Set theme to powerlevel10k
if grep -q '^ZSH_THEME=' "$ZSHRC"; then
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' "$ZSHRC"
else
echo 'ZSH_THEME="powerlevel10k/powerlevel10k"' >> "$ZSHRC"
fi
source "$ZSHRC"
echo "✅ All done!"
echo "➡️ Restart your terminal or run: source ~/.zshrc"