cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
opts="-h --help -v --version --check"
- commands="capabilities check clean fetch list push"
+ commands="check clean"
# 1. First argument: complete commands and global options
if [[ $COMP_CWORD -eq 1 ]]; then
complete -c git-remote-gcrypt -l check -d '(Legacy) Check if URL is a gcrypt repository' -r -F
# Subcommands
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'check' -d 'Check if URL is a gcrypt repository'
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'clean' -d 'Scan/Clean unencrypted files from remote'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'check' -d 'Check if URL is a gcrypt repository'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'clean' -d 'Scan/Clean unencrypted files from remote'
complete -c git-remote-gcrypt -n "__fish_seen_subcommand_from clean check" -a "(git remote -v 2>/dev/null | grep 'gcrypt::' | awk '{print \$1}' | sort -u)" -d 'Gcrypt Remote'
# Clean flags
-complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from capabilities check clean fetch list push" -s f -l force -d 'Actually delete files during clean'
+complete -c git-remote-gcrypt -f -n "__fish_seen_subcommand_from check clean" -s f -l force -d 'Actually delete files during clean'
# Git protocol commands
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'capabilities' -d 'Show git remote helper capabilities'
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'list' -d 'List refs in remote repository'
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'push' -d 'Push refs to remote repository'
-complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from capabilities check clean fetch list push" -a 'fetch' -d 'Fetch refs from remote repository'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'capabilities' -d 'Show git remote helper capabilities'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'list' -d 'List refs in remote repository'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'push' -d 'Push refs to remote repository'
+complete -c git-remote-gcrypt -f -n "not __fish_seen_subcommand_from check clean" -a 'fetch' -d 'Fetch refs from remote repository'
capture = False
for line in lines:
line = line.strip()
- if line.startswith("Options:") or line.startswith("Git Protocol Commands"):
+
+ # Filter out what we don't want in tab completion
+ if line.startswith("Options:"):
capture = True
continue
- if line.startswith("Environment Variables:"):
+ if line.startswith("Git Protocol Commands") or line.startswith(
+ "Environment Variables:"
+ ):
capture = False
continue
help_text = extract_help_text(script_path)
commands = parse_commands(help_text)
- # We always want protocol commands in completions too
- comp_commands = sorted(
- list(set(commands + ["capabilities", "list", "push", "fetch"]))
- )
+ # Optional: remove (or add) any custom preferences here
+ comp_commands = commands
print(f"Detected commands: {' '.join(comp_commands)}")
'(- *)'{-h,--help}'[show help message]'
'(- *)'{-v,--version}'[show version information]'
'--check[check if URL is a gcrypt repository]:URL:_files'
- '1:command:(capabilities check clean fetch list push)'
+ '1:command:(check clean)'
'*::subcommand arguments:->args'
)
_arguments -s -S $args