--- layout: post title: "恢复termux自动" date: 2026-06-14 13:28:38 +08:00 categories: 拾光 随笔 时光存档 tags: 风正扬 --- ================================ # 1. 进入博客仓库 ================================ ```bash cd ~/gitdemo ``` ================================ # 2. 创建配置备份目录 ================================ ```bash mkdir -p config/termux ``` ================================ # 3. 备份核心配置文件 =============================== ```bash cp ~/.myfuncs.sh config/termux/ cp ~/.bashrc config/termux/ cp ~/.zshrc config/termux/ cp ~/.profile config/termux/ ``` ================================ # 4. 创建【终极版】一键恢复脚本 ================================ ```bash cat > config/termux/restore.sh <<'EOF' #!/data/data/com.termux/files/usr/bin/bash # --- 自动安装依赖 --- pkg update -y pkg install -y git zsh curl # --- 自动安装 tmoe-zsh 主题 --- if [ ! -d "$HOME/.config/tmoe-zsh" ]; then bash -c "$(curl -L https://gitee.com/mo2/zsh/raw/master/zsh.sh)" fi # --- 恢复配置文件 --- cp ~/.myfuncs.sh ~/ cp ~/.bashrc ~/ cp ~/.zshrc ~/ cp ~/.profile ~/ # --- 应用配置 --- source ~/.bashrc echo "✅ Termux 配置已恢复" EOF ``` 然后执行 ```bash chmod +x config/termux/restore.sh ./config/termux/restore.sh ``` # --- 自动安装依赖 --- ```bash echo "🔧 正在检查并安装基础依赖..." pkg update -y pkg install -y git zsh curl ``` # --- 自动安装 tmoe-zsh 主题 --- # 文档链接1 中提供了 gitee 和 github 两个源,优先使用国内 gitee 源 ```bash echo "🎨 正在安装 tmoe-zsh 主题..." if [ ! -d "$HOME/.config/tmoe-zsh" ]; then bash -c "$(curl -L https://gitee.com/mo2/zsh/raw/master/zsh.sh)" else echo "tmoe-zsh 已存在,跳过安装。" fi ``` # --- 恢复配置文件 --- ```bash echo "📂 正在恢复配置文件..." cp ~/.myfuncs.sh ~/ cp ~/.bashrc ~/ cp ~/.zshrc ~/ cp ~/.profile ~/ ``` # --- 应用配置 --- ```bash source ~/.bashrc echo "" echo "✅✅✅ Termux 环境、主题及配置已全部恢复完成!" EOF ``` ================================ # 5. 赋予脚本执行权限 =============================== ```bash chmod +x config/termux/restore.sh ``` ================================ # 6. 提交并推送到 GitHub(永久保存) ================================ ```bash git add config/termux git commit -m "更新 restore.sh:集成依赖与主题自动安装" git push gitdemo master 重装 Termux(以后用) ``` ================================ # 1. 基础初始化(只需这两条) ================================ ```bash termux-change-repo # 切换国内源(推荐) termux-setup-storage # 如需访问手机存储则执行 ``` ================================ # 2. 克隆仓库(使用规范的 URL) # ⚠️ 第一次会要求输入: # - GitHub 用户名 # - Personal Access Token(不是密码) ================================ ```bash git clone https://github.com/sxgpyjg/sxgpyjg.github.io.git gitdemo ``` ================================ # 3. 一键全自动恢复(核心步骤) ================================ ```bash cd gitdemo ./config/termux/restore.sh ``` ================================ # 4. 以后日常写作 ================================ ```bash yjg "我的新文章" ```