优化Zsh插件安装流程和命令执行器
- 重构Zsh插件安装逻辑,将硬编码URL拆分为源和目标路径 - 修改RealTimeCommandExecutor,增加实时命令执行日志输出 - 优化SingleLineCommandExecutor日志信息,改进命令日志可读性 - 简化插件安装命令,支持国内外镜像源的插件克隆
This commit is contained in:
@@ -71,18 +71,31 @@ func addZshSubcommands(cmd *cobra.Command) {
|
||||
)
|
||||
}
|
||||
|
||||
op.SingleLineCommandExecutor(installZshCommand)
|
||||
// 执行 oh-my-zsh 安装命令
|
||||
op.RealTimeCommandExecutor(installZshCommand)
|
||||
|
||||
log.Info("安装zsh完成, 开始安装插件!")
|
||||
|
||||
pluginsHardCodeUrl := []string{
|
||||
"https://gitee.com/wangl-cc/zsh-autosuggestions.git /root/.oh-my-zsh/plugins/zsh-autosuggestions",
|
||||
"https://gitee.com/xiaoqqya/zsh-syntax-highlighting.git /root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
|
||||
pluginsHardCodeUrl := [][]string{
|
||||
{
|
||||
"https://gitee.com/wangl-cc/zsh-autosuggestions.git",
|
||||
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
|
||||
},
|
||||
{
|
||||
"https://gitee.com/xiaoqqya/zsh-syntax-highlighting.git",
|
||||
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
|
||||
},
|
||||
}
|
||||
|
||||
pluginsHardCodeOutsideUrl := []string{
|
||||
"https://github.com/zsh-users/zsh-autosuggestions /root/.oh-my-zsh/plugins/zsh-autosuggestions",
|
||||
"https://github.com/zsh-users/zsh-syntax-highlighting.git /root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
|
||||
pluginsHardCodeOutsideUrl := [][]string{
|
||||
{
|
||||
"https://github.com/zsh-users/zsh-autosuggestions",
|
||||
"/root/.oh-my-zsh/plugins/zsh-autosuggestions",
|
||||
},
|
||||
{
|
||||
"https://github.com/zsh-users/zsh-syntax-highlighting.git",
|
||||
"/root/.oh-my-zsh/plugins/zsh-syntax-highlighting",
|
||||
},
|
||||
}
|
||||
|
||||
pluginsListUrl := []string{
|
||||
@@ -91,26 +104,17 @@ func addZshSubcommands(cmd *cobra.Command) {
|
||||
"https://gitea.107421.xyz/zeaslity/ohmyzsh/src/branch/master/plugins/themes/themes.plugin.zsh",
|
||||
}
|
||||
|
||||
if config.ConfigCache.Agent.Network.Internet == 7 {
|
||||
log.Info("使用gitea镜像安装插件!")
|
||||
pluginsHardCodeUrl = append(pluginsHardCodeUrl,
|
||||
"wget -c -i https://b2.107421.xyz/oh-my-zsh-plugins-list.txt -P /root/.oh-my-zsh/plugins/",
|
||||
)
|
||||
|
||||
} else {
|
||||
log.Info("使用github安装插件!")
|
||||
}
|
||||
// 下载插件
|
||||
if config.ConfigCache.Agent.Network.Internet == 7 {
|
||||
// 执行硬编码命令, 安装插件
|
||||
for _, command := range pluginsHardCodeUrl {
|
||||
op.SingleLineCommandExecutor([]string{"git", "clone", command})
|
||||
op.SingleLineCommandExecutor([]string{"git", "clone", command[0], command[1]})
|
||||
}
|
||||
|
||||
} else {
|
||||
// 执行硬编码命令, 安装插件 国外
|
||||
for _, command := range pluginsHardCodeOutsideUrl {
|
||||
op.SingleLineCommandExecutor([]string{"git", "clone", command})
|
||||
op.SingleLineCommandExecutor([]string{"git", "clone", command[0], command[1]})
|
||||
}
|
||||
}
|
||||
// 下载插件
|
||||
|
||||
Reference in New Issue
Block a user