feat: split mise shared config from per-machine tools

Link mise/config.toml into ~/.config/mise/conf.d/dotfile.toml so
mise use -g writes the local config.toml instead of dirtying git.
This commit is contained in:
2026-10-12 16:00:33 +08:00
parent 89ad569581
commit 4fc664d243
3 changed files with 31 additions and 10 deletions
+4 -1
View File
@@ -21,7 +21,8 @@ ff reload # 重载 fish 配置
| `fish/default.fish` | 共享 fish 配置(进 git) |
| `~/.config/fish/config.fish` | 本机 wrapper,仅 `source` default.fish + 可选 `custom.fish` |
| `fish/functions/`、`fish/completions/` | fish 函数与补全;`fish-init` 会软链到 `~/.config/fish/` |
| `git/`、`nvim/`、`tmux/`、`zsh/`、`cursor/`、`ghostty/`、`mise/` 等 | 各工具**真实配置**,由对应 `*-init` 软链到系统路径 |
| `git/`、`nvim/`、`tmux/`、`zsh/`、`cursor/`、`ghostty/` 等 | 各工具**真实配置**,由对应 `*-init` 软链到系统路径 |
| `mise/config.toml` | 跨机器共享;`mise-install` 链到 `~/.config/mise/conf.d/dotfile.toml`。本机工具在 `~/.config/mise/config.toml` |
| `Makefile.scripts` | `make <script-name>` 运行 `script/<name>.sh` |
## 脚本命名
@@ -51,6 +52,7 @@ ff reload # 重载 fish 配置
- 优先用系统包管理器(brew/apt),其次官方安装脚本或 Release 二进制到 `~/.local/bin`
- Debian/Ubuntu 安装类脚本应支持 `CN_REGION` 切换镜像(参考 `docker-install.sh`)
- 需要 root 的脚本在 usage 里写 `sudo`,不要静默假设
- **mise**:共享 `mise/config.toml` 链到 `~/.config/mise/conf.d/dotfile.toml`;`mise use -g` 写本机 `~/.config/mise/config.toml`,不进 git。旧的指向仓库的全局软链由 `mise-install` 解开
## Fish / `ff` 入口
@@ -75,6 +77,7 @@ ff reload # 重载 fish 配置
- 不要把密钥、webhook、本机专用路径写进 git(`script/clash.sh` 等已在 `.gitignore`)
- 不要改 `~/.config/fish/config.fish` 进仓库;本机差异放 `custom.fish`
- 不要把本机 `mise use -g` 的工具写进 `mise/config.toml`;写 `~/.config/mise/config.toml`
- 不要为 init 复制整份配置到 `$HOME`;**优先软链接**到 dotfile
- 脚本改动保持最小 diff,风格与相邻脚本一致(bash、`set -euo pipefail` 视情况)
- 未经明确要求不要 `git commit` / `git push`
+1
View File
@@ -1 +1,2 @@
# 跨机器共享。本机工具写在 ~/.config/mise/config.toml(mise use -g)
[tools]
+26 -9
View File
@@ -1,5 +1,5 @@
#!/bin/bash
# 安装 mise 并链接 dotfile 配置、安装 config.toml 中的工具
# 安装 mise,链接共享配置到 conf.d,安装工具
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
@@ -10,8 +10,9 @@ usage() {
用法: mise-install
1. 若未安装则通过官方脚本安装 mise
2. 链接 ~/.dotfile/mise/config.toml
3. 执行 mise install 安装配置中的工具
2. 链接 ~/.dotfile/mise/config.toml 到 ~/.config/mise/conf.d/dotfile.toml
3. 若全局 config.toml 仍指向仓库,则改为本机实文件(mise use -g 写这里)
4. 执行 mise install 安装配置中的工具
选项:
-h, --help 显示此帮助
@@ -62,15 +63,31 @@ fi
MISE_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/mise"
DOTFILE_MISE_CONFIG="$HOME/.dotfile/mise/config.toml"
mkdir -p "$MISE_CONFIG_DIR"
MISE_GLOBAL_CONFIG="$MISE_CONFIG_DIR/config.toml"
MISE_SHARED_LINK="$MISE_CONFIG_DIR/conf.d/dotfile.toml"
mkdir -p "$MISE_CONFIG_DIR/conf.d"
if [ -f "$DOTFILE_MISE_CONFIG" ]; then
if [ -f "$MISE_CONFIG_DIR/config.toml" ] && [ ! -L "$MISE_CONFIG_DIR/config.toml" ]; then
mv "$MISE_CONFIG_DIR/config.toml" "$MISE_CONFIG_DIR/config.toml.bak"
echo -e "${YELLOW}已备份原有配置到 config.toml.bak${NC}"
# 旧布局:全局 config.toml 软链进仓库,mise use -g 会弄脏 git
if [ -L "$MISE_GLOBAL_CONFIG" ] &&
[ "$(readlink -f "$MISE_GLOBAL_CONFIG")" = "$(readlink -f "$DOTFILE_MISE_CONFIG")" ]; then
rm -f "$MISE_GLOBAL_CONFIG"
echo -e "${YELLOW}已解开指向仓库的全局 config.toml 软链,改为本机文件${NC}"
fi
ln -sf "$DOTFILE_MISE_CONFIG" "$MISE_CONFIG_DIR/config.toml"
echo -e "${GREEN}已链接 mise 配置: $MISE_CONFIG_DIR/config.toml${NC}"
ln -sf "$DOTFILE_MISE_CONFIG" "$MISE_SHARED_LINK"
echo -e "${GREEN}已链接共享 mise 配置: $MISE_SHARED_LINK${NC}"
mise trust "$DOTFILE_MISE_CONFIG" 2>/dev/null || true
if [ ! -e "$MISE_GLOBAL_CONFIG" ]; then
cat >"$MISE_GLOBAL_CONFIG" <<'EOF'
# 本机工具(mise use -g)。共享配置: ~/.dotfile/mise/config.toml
[tools]
EOF
echo -e "${GREEN}已创建本机 mise 配置: $MISE_GLOBAL_CONFIG${NC}"
fi
mise trust "$MISE_GLOBAL_CONFIG" 2>/dev/null || true
fi
if command -v mise &>/dev/null && [ -f "$MISE_CONFIG_DIR/config.toml" ]; then