Repository navigation
envSwitch v0.1.3
v0.1.3 (2026-05-18)
Changed — Architecture: shell function → precmd hook + env.sh
Removed the envswitch() shell function wrapper entirely and replaced it with a clean precmd hook architecture:
cover/uncover/autono longer outputexportstatements to stdout. They write~/.envswitch/state/env.shinstead.- Shell init block now uses a
precmdhook (zsh) /PROMPT_COMMAND(bash) that sourcesenv.shon every prompt. - Environment variables (JAVA_HOME, GOROOT, etc.) refresh automatically on the next prompt after a
coveroperation. which envswitchnow returns only the binary path — no more shell function pollution.envswitch initwrites.zshrc/.bashrcfor new terminals, and prints a hint tosource ~/.envswitch/init.shfor immediate effect in the current terminal.envswitch uninitremoves the init block and prints cleanup instructions for the current shell session.load-globalsis no longer called by the init block (replaced by directsource env.shat startup).
Added — GUI: CLI init detection + Doctor diagnostics
cover_modulenow checks that the envSwitch CLI binary is available (via PATH search) and that shell integration is initialized before allowing cover operations. If not, a clear error message is shown.- Doctor page adds two new diagnostic checks:
- envSwitch CLI available — verifies the CLI binary exists in PATH (not the GUI app bundle).
- Shell integration initialized — checks
.zshrc/.bashrcfor the init block.
Fixed — CLI path detection
check_init_status()now finds the real CLI binary by searching PATH (equivalent towhich envswitch) and common install locations (~/.cargo/bin/,/usr/local/bin/,/opt/homebrew/bin/), instead of returning the GUI app bundle path.
Fixed — Build warnings
- Suppressed
dead_codewarnings on library items that are consumed by the GUI crate but unreferenced by the CLI binary target.
v0.1.3 (2026-05-18)
变更 — 架构重构:shell function → precmd hook + env.sh
彻底移除 envswitch() shell function 包装,改为干净的 precmd hook 架构:
cover/uncover/auto不再向 stdout 输出export语句,改为写入~/.envswitch/state/env.sh。- Shell init block 使用
precmdhook(zsh)/PROMPT_COMMAND(bash),在每个提示符自动 sourceenv.sh。 JAVA_HOME、GOROOT等环境变量在cover操作后的下一次提示符自动刷新。which envswitch现在只返回 binary 路径 — 不再有 shell function 污染。envswitch init为新终端写入.zshrc/.bashrc,并提示source ~/.envswitch/init.sh使当前终端立即生效。envswitch uninit移除 init block 并打印当前 shell 会话清理指令。load-globals不再被 init block 调用(改为启动时直接source env.sh)。
新增 — GUI:CLI 初始化检测 + 诊断增强
cover_module在允许 cover 操作前检查 envSwitch CLI 二进制是否可用(通过 PATH 搜索)以及 Shell 集成是否已初始化。未初始化时显示明确错误提示。- 诊断页面新增两项检查:
- envSwitch 命令行可用 — 验证 CLI 二进制在 PATH 中存在(而非 GUI app bundle 路径)。
- Shell 集成已初始化 — 检查
.zshrc/.bashrc中的 init block。
修复 — CLI 路径检测
check_init_status()现在通过搜索 PATH(等同于which envswitch)和常见安装位置(~/.cargo/bin/、/usr/local/bin/、/opt/homebrew/bin/)来查找真正的 CLI 二进制,而非返回 GUI app bundle 路径。
修复 — 编译警告
- 对仅被 GUI crate 引用、未被 CLI binary target 使用的库项添加了
#[allow(dead_code)],消除编译警告。
Full Changelog: v0.1.2...v0.1.3