Fix zsh plugin installation issues
- Remove problematic git submodules for custom plugins - Update install script to properly handle plugin installation - Add test-plugins.sh script to verify plugin installation - Update README with troubleshooting for auto-suggestions - Ensure plugins are downloaded fresh on each installation
This commit is contained in:
parent
92febc12aa
commit
7fe25f26c9
|
|
@ -105,6 +105,22 @@ sync-zsh-config
|
|||
|
||||
## 故障排除
|
||||
|
||||
### 如果自动建议插件不工作
|
||||
```bash
|
||||
# 运行测试脚本检查插件状态
|
||||
chmod +x /root/mgmt/configuration/zsh/test-plugins.sh
|
||||
/root/mgmt/configuration/zsh/test-plugins.sh
|
||||
|
||||
# 手动安装缺失的插件
|
||||
cd ~/.oh-my-zsh/custom/plugins
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
git clone https://github.com/zsh-users/zsh-completions
|
||||
|
||||
# 重新加载配置
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
### 如果同步失败
|
||||
```bash
|
||||
# 检查网络连接
|
||||
|
|
@ -129,6 +145,9 @@ alias | grep <alias-name>
|
|||
# 检查插件目录
|
||||
ls ~/.oh-my-zsh/plugins/
|
||||
ls ~/.oh-my-zsh/custom/plugins/
|
||||
|
||||
# 运行测试脚本
|
||||
/root/mgmt/configuration/zsh/test-plugins.sh
|
||||
```
|
||||
|
||||
## 安全说明
|
||||
|
|
|
|||
|
|
@ -126,8 +126,10 @@ deploy_configs() {
|
|||
# 部署自定义配置
|
||||
if [[ -d "$script_dir/oh-my-zsh-custom" ]]; then
|
||||
log_info "部署自定义 oh-my-zsh 配置..."
|
||||
# 只复制非 git 仓库的文件
|
||||
find "$script_dir/oh-my-zsh-custom" -type f -not -path "*/.git/*" -exec cp --parents {} "$HOME/.oh-my-zsh/custom/" \;
|
||||
# 复制自定义别名文件
|
||||
if [[ -f "$script_dir/oh-my-zsh-custom/aliases.zsh" ]]; then
|
||||
cp "$script_dir/oh-my-zsh-custom/aliases.zsh" "$HOME/.oh-my-zsh/custom/"
|
||||
fi
|
||||
fi
|
||||
|
||||
log_success "配置文件部署完成"
|
||||
|
|
@ -205,8 +207,9 @@ fi
|
|||
log_info "部署新配置..."
|
||||
cp "$ZSH_CONFIG_DIR/zshrc.template" "$HOME/.zshrc"
|
||||
|
||||
if [[ -d "$ZSH_CONFIG_DIR/oh-my-zsh-custom" ]]; then
|
||||
cp -r "$ZSH_CONFIG_DIR/oh-my-zsh-custom"/* "$HOME/.oh-my-zsh/custom/"
|
||||
# 部署自定义别名
|
||||
if [[ -f "$ZSH_CONFIG_DIR/oh-my-zsh-custom/aliases.zsh" ]]; then
|
||||
cp "$ZSH_CONFIG_DIR/oh-my-zsh-custom/aliases.zsh" "$HOME/.oh-my-zsh/custom/"
|
||||
fi
|
||||
|
||||
log_success "ZSH 配置同步完成!"
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
# Add your own custom plugins in the custom/plugins directory. Plugins placed
|
||||
# here will override ones with the same name in the main plugins directory.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 85919cd1ffa7d2d5412f6d3fe437ebdbeeec4fc5
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit d08cee09cecdc2d95bf501183597411a7632be7c
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 5eb677bb0fa9a3e60f0eff031dc13926e093df92
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 测试 ZSH 插件是否正确安装
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# 颜色定义
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
test_plugin() {
|
||||
local plugin_name="$1"
|
||||
local plugin_path="$2"
|
||||
|
||||
if [[ -d "$plugin_path" ]]; then
|
||||
log_success "✓ $plugin_name 已安装"
|
||||
return 0
|
||||
else
|
||||
log_error "✗ $plugin_name 未安装: $plugin_path"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_alias() {
|
||||
local alias_name="$1"
|
||||
|
||||
if alias "$alias_name" &>/dev/null; then
|
||||
log_success "✓ 别名 $alias_name 已加载"
|
||||
return 0
|
||||
else
|
||||
log_warning "✗ 别名 $alias_name 未加载"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
log_info "测试 ZSH 插件和配置..."
|
||||
echo ""
|
||||
|
||||
local failed=0
|
||||
|
||||
# 测试 oh-my-zsh 安装
|
||||
log_info "检查 oh-my-zsh 安装..."
|
||||
if [[ -d "$HOME/.oh-my-zsh" ]]; then
|
||||
log_success "✓ oh-my-zsh 已安装"
|
||||
else
|
||||
log_error "✗ oh-my-zsh 未安装"
|
||||
((failed++))
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 测试自定义插件
|
||||
log_info "检查自定义插件..."
|
||||
test_plugin "zsh-autosuggestions" "$HOME/.oh-my-zsh/custom/plugins/zsh-autosuggestions" || ((failed++))
|
||||
test_plugin "zsh-syntax-highlighting" "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" || ((failed++))
|
||||
test_plugin "zsh-completions" "$HOME/.oh-my-zsh/custom/plugins/zsh-completions" || ((failed++))
|
||||
echo ""
|
||||
|
||||
# 测试内置插件
|
||||
log_info "检查内置插件..."
|
||||
test_plugin "git" "$HOME/.oh-my-zsh/plugins/git" || ((failed++))
|
||||
test_plugin "docker" "$HOME/.oh-my-zsh/plugins/docker" || ((failed++))
|
||||
test_plugin "ansible" "$HOME/.oh-my-zsh/plugins/ansible" || ((failed++))
|
||||
test_plugin "terraform" "$HOME/.oh-my-zsh/plugins/terraform" || ((failed++))
|
||||
test_plugin "kubectl" "$HOME/.oh-my-zsh/plugins/kubectl" || ((failed++))
|
||||
echo ""
|
||||
|
||||
# 测试自定义别名文件
|
||||
log_info "检查自定义别名..."
|
||||
if [[ -f "$HOME/.oh-my-zsh/custom/aliases.zsh" ]]; then
|
||||
log_success "✓ 自定义别名文件已安装"
|
||||
else
|
||||
log_warning "✗ 自定义别名文件未安装"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 测试一些关键别名
|
||||
log_info "检查关键别名..."
|
||||
test_alias "mgmt" || ((failed++))
|
||||
test_alias "dps" || ((failed++))
|
||||
test_alias "k" || ((failed++))
|
||||
test_alias "gs" || ((failed++))
|
||||
echo ""
|
||||
|
||||
# 测试 .zshrc 文件
|
||||
log_info "检查 .zshrc 配置..."
|
||||
if [[ -f "$HOME/.zshrc" ]]; then
|
||||
log_success "✓ .zshrc 文件存在"
|
||||
|
||||
# 检查关键配置
|
||||
if grep -q "zsh-autosuggestions" "$HOME/.zshrc"; then
|
||||
log_success "✓ zsh-autosuggestions 已配置"
|
||||
else
|
||||
log_warning "✗ zsh-autosuggestions 未配置"
|
||||
fi
|
||||
|
||||
if grep -q "zsh-syntax-highlighting" "$HOME/.zshrc"; then
|
||||
log_success "✓ zsh-syntax-highlighting 已配置"
|
||||
else
|
||||
log_warning "✗ zsh-syntax-highlighting 未配置"
|
||||
fi
|
||||
|
||||
if grep -q "agnoster" "$HOME/.zshrc"; then
|
||||
log_success "✓ agnoster 主题已配置"
|
||||
else
|
||||
log_warning "✗ agnoster 主题未配置"
|
||||
fi
|
||||
else
|
||||
log_error "✗ .zshrc 文件不存在"
|
||||
((failed++))
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# 总结
|
||||
if [[ $failed -eq 0 ]]; then
|
||||
log_success "🎉 所有测试通过!ZSH 配置完整。"
|
||||
echo ""
|
||||
log_info "使用方法:"
|
||||
echo " - 重新登录或运行: source ~/.zshrc"
|
||||
echo " - 测试自动建议: 输入 'docker' 然后按 → 键"
|
||||
echo " - 测试别名: 运行 'mgmt-status' 或 'dps'"
|
||||
else
|
||||
log_error "❌ 发现 $failed 个问题,请检查安装。"
|
||||
echo ""
|
||||
log_info "修复建议:"
|
||||
echo " 1. 重新运行安装脚本"
|
||||
echo " 2. 检查网络连接"
|
||||
echo " 3. 手动安装缺失的插件"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Loading…
Reference in New Issue