From 6e545512726837a9d5959afc8fe22d396f900c0d Mon Sep 17 00:00:00 2001 From: tuong Date: Sun, 13 Jul 2025 03:36:32 +0700 Subject: [PATCH] - Init commit --- .../00-install-oh-my-zsh-plugins-script.sh | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 terminal-releate-script/oh-my-zsh-script/00-install-oh-my-zsh-plugins-script.sh diff --git a/terminal-releate-script/oh-my-zsh-script/00-install-oh-my-zsh-plugins-script.sh b/terminal-releate-script/oh-my-zsh-script/00-install-oh-my-zsh-plugins-script.sh new file mode 100755 index 0000000..239ccdc --- /dev/null +++ b/terminal-releate-script/oh-my-zsh-script/00-install-oh-my-zsh-plugins-script.sh @@ -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"