mgmt/configuration/zsh
Houzhong Xu 8861d81371
Add proxy toggle script for easy proxy management
- Add proxy-toggle.sh script with full proxy control functionality
- Support temporary and permanent proxy enable/disable
- Add proxy status checking and connection testing
- Include convenient aliases: proxy-on, proxy-off, proxy-toggle, etc.
- Automatic IP display when switching proxy states
- Configuration file management for persistent proxy settings
2025-09-20 17:31:03 +00:00
..
oh-my-zsh-custom Add proxy toggle script for easy proxy management 2025-09-20 17:31:03 +00:00
README.md Fix zsh plugin installation issues 2025-09-20 17:23:45 +00:00
install-zsh-config.sh Fix zsh plugin installation issues 2025-09-20 17:23:45 +00:00
quick-install.sh Add zsh configuration sync system 2025-09-20 17:19:32 +00:00
test-plugins.sh Fix zsh plugin installation issues 2025-09-20 17:23:45 +00:00
zshrc.template Add zsh configuration sync system 2025-09-20 17:19:32 +00:00

README.md

ZSH 配置同步方案

这个目录包含了完整的 oh-my-zsh 配置,可以在多个 VPS 之间同步使用。

文件结构

configuration/zsh/
├── README.md                    # 本文件
├── install-zsh-config.sh        # 完整安装脚本
├── quick-install.sh            # 快速安装脚本
├── zshrc.template              # ZSH 配置文件模板
└── oh-my-zsh-custom/           # 自定义 oh-my-zsh 配置
    ├── aliases.zsh             # 自定义别名
    └── plugins/                # 自定义插件

使用方法

方法一:快速安装(推荐)

在新 VPS 上运行:

# 一键安装
curl -fsSL https://ben:8d7d70f324796be650b79415303c31f567bf459b@gitea.tailnet-68f9.ts.net/ben/mgmt/raw/branch/main/configuration/zsh/quick-install.sh | bash

方法二:手动安装

  1. 克隆仓库:
git clone https://ben:8d7d70f324796be650b79415303c31f567bf459b@gitea.tailnet-68f9.ts.net/ben/mgmt.git /root/mgmt
  1. 运行安装脚本:
cd /root/mgmt
chmod +x configuration/zsh/install-zsh-config.sh
./configuration/zsh/install-zsh-config.sh

配置同步

安装完成后,可以使用以下命令同步最新配置:

# 同步配置
sync-zsh-config

这个命令会:

  1. 从 Gitea 拉取最新配置
  2. 备份当前配置
  3. 部署新配置

包含的功能

插件

  • git - Git 集成
  • docker - Docker 支持
  • ansible - Ansible 支持
  • terraform - OpenTofu/Terraform 支持
  • kubectl - Kubernetes 支持
  • zsh-autosuggestions - 命令自动建议
  • zsh-syntax-highlighting - 语法高亮
  • zsh-completions - 增强补全

别名

  • 项目管理: mgmt-status, mgmt-deploy, mgmt-cleanup
  • Ansible: ansible-check, ansible-deploy, ansible-ping
  • OpenTofu: tofu-init, tofu-plan, tofu-apply
  • Docker: dps, dex, dlog, dclean
  • Kubernetes: k, kgp, kgs, kaf
  • Git: gs, ga, gc, gp, gl
  • 系统: ll, la, ports, myip

主题

  • agnoster - 功能丰富的主题,显示 Git 状态

更新配置

当您在主 VPS 上更新配置后:

  1. 提交更改:
cd /root/mgmt
git add configuration/zsh/
git commit -m "Update zsh configuration"
git push origin main
  1. 在其他 VPS 上同步:
sync-zsh-config

自定义配置

如果您需要在特定 VPS 上添加自定义配置:

  1. 编辑 ~/.zshrc 文件
  2. 在文件末尾添加您的自定义配置
  3. 这些配置不会被同步脚本覆盖

故障排除

如果自动建议插件不工作

# 运行测试脚本检查插件状态
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

如果同步失败

# 检查网络连接
ping gitea.tailnet-68f9.ts.net

# 手动拉取
cd /root/mgmt
git pull origin main

如果别名不工作

# 重新加载配置
source ~/.zshrc

# 检查别名
alias | grep <alias-name>

如果插件不工作

# 检查插件目录
ls ~/.oh-my-zsh/plugins/
ls ~/.oh-my-zsh/custom/plugins/

# 运行测试脚本
/root/mgmt/configuration/zsh/test-plugins.sh

安全说明

  • 此配置包含访问 Gitea 的凭据
  • 请确保只在可信的 VPS 上使用
  • 建议定期更新访问令牌

支持

如有问题,请检查:

  1. 网络连接是否正常
  2. Git 凭据是否正确
  3. 依赖包是否已安装
  4. 权限是否正确