wiki-switch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Wiki Switch — Manage Multiple Vault Profiles

Wiki Switch — 管理多个Vault配置文件

Each vault is a complete config file at
~/.obsidian-wiki/config.<name>
. The active vault is whichever file
~/.obsidian-wiki/config
symlinks to. Switching vaults means re-pointing that symlink.
每个vault都是
~/.obsidian-wiki/config.<name>
路径下的完整配置文件。当前激活的vault是
~/.obsidian-wiki/config
符号链接指向的文件。切换vault意味着重新指向该符号链接。

Dispatch

指令分发

Parse the invocation and route to the right section:
InvocationAction
/wiki-switch <name>
Switch
/wiki-switch list
List
/wiki-switch show [name]
Show
/wiki-switch new <name>
New
/wiki-switch
(no args)
List (treat as list)

解析调用指令并路由到对应功能模块:
调用指令操作
/wiki-switch <name>
切换
/wiki-switch list
列出
/wiki-switch show [name]
查看
/wiki-switch new <name>
新建
/wiki-switch
(无参数)
列出(视为列出操作)

Switch (default action)

切换(默认操作)

Activate a named vault profile.
  1. Verify
    ~/.obsidian-wiki/config.<name>
    exists. If not, tell the user the vault doesn't exist and list what's available (run List).
  2. Run:
    bash
    ln -sf ~/.obsidian-wiki/config.<name> ~/.obsidian-wiki/config
  3. Read
    OBSIDIAN_VAULT_PATH
    from the newly active config.
  4. Confirm to the user:
    Switched to vault: <name>
    Vault path: <value of OBSIDIAN_VAULT_PATH from the config>

激活指定名称的vault配置文件。
  1. 验证
    ~/.obsidian-wiki/config.<name>
    是否存在。如果不存在,告知用户该vault不存在并列出可用的vault(执行列出操作)。
  2. 运行以下命令:
    bash
    ln -sf ~/.obsidian-wiki/config.<name> ~/.obsidian-wiki/config
  3. 从新激活的配置文件中读取
    OBSIDIAN_VAULT_PATH
  4. 向用户确认:
    已切换到vault: <name>
    Vault路径: <配置文件中OBSIDIAN_VAULT_PATH的值>

List

列出

Show all registered vault profiles and which is active.
  1. Find all files matching
    ~/.obsidian-wiki/config.*
    (exclude
    config
    itself — that's the symlink).
  2. Resolve the current symlink target:
    readlink ~/.obsidian-wiki/config
  3. For each config file, read the first non-empty comment line (lines starting with
    #
    ) as a human description of the vault. Fall back to the file's suffix as the label if no comment exists.
  4. Display:
    Vaults:
      personal   My personal research wiki    ← active
      work       Work projects wiki
    Mark the active one with
    ← active
    . If the symlink is broken or
    config
    doesn't exist, show
    (none active)
    .

显示所有已注册的vault配置文件以及当前激活的vault。
  1. 查找所有匹配
    ~/.obsidian-wiki/config.*
    的文件(排除
    config
    本身——这是符号链接)。
  2. 获取当前符号链接的目标:
    readlink ~/.obsidian-wiki/config
  3. 对于每个配置文件,读取第一个非空注释行(以
    #
    开头的行)作为vault的人工描述。如果没有注释行,则使用文件的后缀作为标签。
  4. 显示格式如下:
    Vault列表:
      personal   我的个人研究wiki    ← 当前激活
      work       工作项目wiki
    ← 当前激活
    标记当前激活的vault。如果符号链接损坏或
    config
    不存在,则显示
    (无激活vault)

Show

查看

Print the full config for a vault.
  • If a name is given, read
    ~/.obsidian-wiki/config.<name>
    .
  • If no name given, read
    ~/.obsidian-wiki/config
    (the active vault).
  • If the file doesn't exist, tell the user and list what's available.
  • Print the file contents verbatim (redact any lines containing
    API_KEY
    or
    SECRET
    — show
    ***
    instead of the value).

打印vault的完整配置内容。
  • 如果指定了名称,读取
    ~/.obsidian-wiki/config.<name>
  • 如果未指定名称,读取
    ~/.obsidian-wiki/config
    (当前激活的vault)。
  • 如果文件不存在,告知用户并列出可用的vault。
  • 逐字打印文件内容(对包含
    API_KEY
    SECRET
    的行进行脱敏处理——用
    ***
    替代对应值)。

New

新建

Scaffold a new vault config from the current active config as a template.
  1. Check
    ~/.obsidian-wiki/config.<name>
    doesn't already exist. Abort if it does.
  2. Copy the active config:
    bash
    cp ~/.obsidian-wiki/config ~/.obsidian-wiki/config.<name>
  3. Read the copied config. Config files use
    # --- Section name ---
    comment headers to group fields into sections (e.g.,
    # --- Vault-specific ---
    ,
    # --- Vault-independent ---
    ,
    # --- Secrets ---
    ). Use these sections to determine what to ask about:
    • Fields in sections labeled "vault-specific", "paths", or similar → ask the user for new values
    • Fields in sections labeled "vault-independent", "global", "shared" → keep as-is (copy over unchanged)
    • Fields in sections labeled "secrets" → ask if the new vault uses the same credentials or different ones
    • If there are no section headers, present all fields and let the user decide which to change
  4. Ask the user for updated values for the vault-specific fields. Use the current values as visible defaults — the user only needs to supply what differs.
  5. Write the updated values into
    ~/.obsidian-wiki/config.<name>
    .
  6. Update the top comment line to describe the new vault (e.g.,
    # Obsidian Wiki — <name> vault
    ).
  7. Confirm:
    Created: ~/.obsidian-wiki/config.<name>
    Run `/wiki-switch <name>` to activate it.
    Do not switch automatically — let the user decide when to activate.
以当前激活的配置文件为模板,生成新的vault配置文件。
  1. 检查
    ~/.obsidian-wiki/config.<name>
    是否已存在。如果存在则终止操作。
  2. 复制当前激活的配置文件:
    bash
    cp ~/.obsidian-wiki/config ~/.obsidian-wiki/config.<name>
  3. 读取复制后的配置文件。配置文件使用
    # --- 章节名称 ---
    注释标题将字段分组为不同章节(例如
    # --- Vault专属配置 ---
    # --- Vault通用配置 ---
    # --- 机密信息 ---
    )。根据这些章节决定需要询问用户的内容:
    • 标记为“vault专属配置”、“路径”或类似名称的章节中的字段 → 询问用户新值
    • 标记为“vault通用配置”、“全局”、“共享”的章节中的字段 → 保持原样(直接复制不变)
    • 标记为“机密信息”的章节中的字段 → 询问用户新vault是否使用相同的凭据或不同的凭据
    • 如果没有章节标题,则展示所有字段并让用户决定需要修改哪些
  4. 询问用户vault专属字段的更新值。将当前值设为可见默认值——用户只需提供与默认值不同的内容即可。
  5. 将更新后的值写入
    ~/.obsidian-wiki/config.<name>
  6. 更新顶部注释行以描述新vault(例如
    # Obsidian Wiki — <name> vault
    )。
  7. 向用户确认:
    已创建: ~/.obsidian-wiki/config.<name>
    运行`/wiki-switch <name>`以激活它。
    不要自动切换——让用户决定何时激活。