feat(completion): 自动安装 shell 补全,迁移旧配置并清理手动补全

This commit is contained in:
Zhengshou Lai
2026-07-04 19:24:58 +08:00
parent 9b7439fdc6
commit 1ee5a31ccf
12 changed files with 478 additions and 84 deletions
+4 -25
View File
@@ -1,10 +1,6 @@
ROOT_DIR := $(shell pwd)
COMP_DIR := $(HOME)/.local/bin/completions
PYTHON ?= python3
# 手动安装的文件清单(与 bin/commands/self_mgmt.py 中的 _MANUAL_FILES 保持同步)
MANUAL_FILES := $(COMP_DIR)/_mytoolkit $(COMP_DIR)/mytoolkit.bash
.PHONY: help install uninstall sync-skill
help:
@@ -12,22 +8,12 @@ help:
@echo ""
@echo " install Install mytoolkit in editable mode (current Python) and sync skill"
@echo " sync-skill Copy the bundled Claude skill to ~/.claude/skills/mytoolkit/"
@echo " uninstall Uninstall mytoolkit and remove completions"
@echo " uninstall Uninstall mytoolkit and remove shell completions"
install:
$(PYTHON) -m pip install -e "$(ROOT_DIR)" --upgrade
@echo "Installing completions…"
@mkdir -p "$(COMP_DIR)"
@SHELL_NAME=$$(basename "$$SHELL"); \
if [ "$$SHELL_NAME" = "zsh" ]; then \
_MYTOOLKIT_COMPLETE=zsh_source mytoolkit > "$(COMP_DIR)/_mytoolkit" && \
echo "zsh completion: $(COMP_DIR)/_mytoolkit" || \
echo "Warning: zsh completion failed"; \
elif [ "$$SHELL_NAME" = "bash" ]; then \
_MYTOOLKIT_COMPLETE=bash_source mytoolkit > "$(COMP_DIR)/mytoolkit.bash" && \
echo "bash completion: $(COMP_DIR)/mytoolkit.bash" || \
echo "Warning: bash completion failed"; \
fi
@echo "Installing shell completions…"
@mytoolkit completion install || echo "Warning: completion install failed"
@$(MAKE) -s sync-skill
sync-skill:
@@ -41,11 +27,4 @@ sync-skill:
fi
uninstall:
$(PYTHON) -m pip uninstall mytoolkit -y
@for f in $(MANUAL_FILES); do \
if [ -e "$$f" ] || [ -L "$$f" ]; then \
rm -f "$$f"; \
echo "Removed $$f"; \
fi; \
done
@echo "Uninstalled mytoolkit and cleaned up manual files"
@mytoolkit uninstall || $(PYTHON) -m pip uninstall mytoolkit -y