设置ssh经典高亮风格 #gentoo
# 1. 智能检测并安装 zsh, git, curl (适配 Ubuntu/Debian/CentOS)
if command -v apt >/dev/null; then apt update && apt install -y zsh git curl; else yum install -y zsh git curl; fi
# 2. 官方静默安装 Oh My Zsh
# (如果已存在文件夹会自动备份或跳过,不影响后续)
if [ -d "$HOME/.oh-my-zsh" ]; then echo "Oh My Zsh detected, skipping install..."; else sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended; fi
# 3. 下载两个核心插件 (自动建议 + 语法高亮)
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 2>/dev/null || echo "Plugin autosuggestions already exists"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting 2>/dev/null || echo "Plugin syntax-highlighting already exists"
# 4. 修改配置文件 (核心步骤)
# 设置主题为 gentoo (经典风格)
sed -i 's/ZSH_THEME=".*"/ZSH_THEME="gentoo"/' ~/.zshrc
# 启用插件
sed -i 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' ~/.zshrc
# 5. 更改默认 Shell 并立即进入 Zsh
chsh -s $(which zsh)
echo "✅ 部署完成!主题已设置为经典风格 (gentoo)。正在进入..."
zsh