1
0
Fork 0

Merging upstream version 0.16.7.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-11 18:52:12 +01:00
parent 6b6067194b
commit cf5dbba8e5
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
15 changed files with 737 additions and 81 deletions

View file

@ -1,46 +0,0 @@
_gita_completions()
{
local cur commands repos cmd
local COMP_CWORD COMP_WORDS # 定义变量cur表示当前光标下的单词
read -cn COMP_CWORD # 所有指令集
read -Ac COMP_WORDS # 当前指令的索引值
cur=${COMP_WORDS[COMP_CWORD]}
cmd=${COMP_WORDS[2]}
# FIXME: this is somewhat slow
commands=`gita -h | sed '2q;d' |sed 's/[{}.,]/ /g'`
repos=`gita ls`
# this doesn't work for two repos with the same basename
#gita_path=${XDG_CONFIG_HOME:-$HOME/.config}/gita/repo_path
#repos=`awk '{split($0, paths, ":")} END {for (i in paths) {n=split(paths[i],b, /\//); print b[n]}}' ${gita_path}`
# FIXME(Steve-Xyh): the secondary auto-completion(such as `$repos`) contains first commands / 二级补全候选项中包含一级补全中的 `$commands`
# XXX(Steve-Xyh): the auto-completion is currently case-sensitive / 当前的补全区分大小写, 应该改成大小写不敏感
# (Steve-Xyh): args in zsh must be `reply` / zsh 中的参数必须为 `reply`
if [ -z "$cmd" ]; then
reply=($(compgen -W "${commands}" ${cur}))
else
cmd_reply=($(compgen -W "${commands}" ${cmd}))
case $cmd in
add)
reply=(cmd_reply $(compgen -d ${cur}))
;;
ll)
return
;;
*)
reply=($cmd_reply $(compgen -W "${repos}" ${cur}))
;;
esac
fi
}
# (Steve-Xyh): functions in zsh must be `compctl` / zsh 中必须用 compctl 函数, -K 表示使用函数
compctl -K _gita_completions gita