From 0038d6f0a71248db66b7b0add5ebe859bbda0920 Mon Sep 17 00:00:00 2001 From: Gchuchu <2085471348@qq.com> Date: Sat, 21 Mar 2026 16:10:08 +0800 Subject: [PATCH] Add completion feature when build chsrc --- Makefile | 1 + pkg/deb/debian/postinst | 1 + .../bash_completion.sh} | 11 +++++++---- 3 files changed, 9 insertions(+), 4 deletions(-) rename tool/{chsrc_completion.sh => completion/bash_completion.sh} (94%) diff --git a/Makefile b/Makefile index 1345d176..54fec5a8 100755 --- a/Makefile +++ b/Makefile @@ -219,6 +219,7 @@ clean-deb: install: $(ReleaseMode-Target-Name) install -D -m 755 $(ReleaseMode-Target-Name) $(DESTDIR)/usr/bin/chsrc install -D -m 644 doc/chsrc.1 $(DESTDIR)/usr/share/man/man1/chsrc.1 + install -D -m 644 tool/completion/bash_completion.sh $(DESTDIR)/usr/share/bash-completion/completions/chsrc # 这样还是太麻烦,不用,我们还是靠 just 来调用吧 # diff --git a/pkg/deb/debian/postinst b/pkg/deb/debian/postinst index 39b73a9e..8bf948f7 100755 --- a/pkg/deb/debian/postinst +++ b/pkg/deb/debian/postinst @@ -25,6 +25,7 @@ case "$1" in chmod +x /usr/bin/chsrc echo "chsrc has been successfully installed!" + echo "Please restart your terminal or open a new terminal to enjoy autocompletion" echo "Run 'chsrc help' to get started." ;; diff --git a/tool/chsrc_completion.sh b/tool/completion/bash_completion.sh similarity index 94% rename from tool/chsrc_completion.sh rename to tool/completion/bash_completion.sh index fd72f713..78a64de7 100644 --- a/tool/chsrc_completion.sh +++ b/tool/completion/bash_completion.sh @@ -3,16 +3,19 @@ # -------------------------------------------------------------- # Build File : chsrc_completion.sh # File Authors : 郭恒 <2085471348@qq.com> -# +# Contributors : Nil Null +# | # Created On : <2026-03-19> -# Last Modified : <2026-03-20> -# ============================================================================== +# Last Modified : <2026-03-21> +# +# ------------------------------------------------------------------------------ # chsrc 的 Bash 自动补全脚本(当前仅在Linux Ubuntu中测试过) # # 目标操作系统:Linux # +# @issue https://github.com/RubyMetric/chsrc/issues/204 # source chsrc_completion.sh # 当前终端立即生效 -# ============================================================================== +# ------------------------------------------------------------------------------ _chsrc() {