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:
+26
-9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user