diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-23 11:18:05 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-23 11:18:05 +0200 |
| commit | 9b2328bcb46b1b5fd074fdbc2c4bea8855220276 (patch) | |
| tree | f3936da4c051796dbf51983bbfa309b095bd241c /completions | |
| download | gitctl-9b2328bcb46b1b5fd074fdbc2c4bea8855220276.tar.gz gitctl-9b2328bcb46b1b5fd074fdbc2c4bea8855220276.zip | |
Initial commit: gitctl
Thin CLI plus a server helper (run as the git user) to manage repos on a
personal gitolite3 + cgit server over a command=-restricted SSH key. Includes
the client, the helper, bash completion, a Claude Code skill, and docs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'completions')
| -rw-r--r-- | completions/gitctl.bash | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/completions/gitctl.bash b/completions/gitctl.bash new file mode 100644 index 0000000..0b680dd --- /dev/null +++ b/completions/gitctl.bash @@ -0,0 +1,48 @@ +# bash completion for gitctl +# install: cp completions/gitctl.bash /etc/bash_completion.d/gitctl +# or: source completions/gitctl.bash (from ~/.bashrc) + +_gitctl() { + local cur prev words cword + _init_completion 2>/dev/null || { + # minimal fallback if bash-completion's _init_completion is absent + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + words=("${COMP_WORDS[@]}") + cword=$COMP_CWORD + } + + local group=${words[1]} action=${words[2]} + + # complete section names from the live server (one ssh call). Only when the + # previous word is --section, so we do not pay it on every Tab. + if [[ $prev == "--section" ]]; then + local secs + secs=$(gitctl sections list 2>/dev/null) + local IFS=$'\n' + COMPREPLY=($(compgen -W "$secs" -- "$cur")) + return + fi + + case $cword in + 1) + COMPREPLY=($(compgen -W "sections sync repo" -- "$cur")) + return ;; + 2) + case $group in + sections) COMPREPLY=($(compgen -W "list add" -- "$cur")) ;; + repo) COMPREPLY=($(compgen -W "create desc add-remote" -- "$cur")) ;; + esac + return ;; + esac + + # flags, by subcommand + if [[ $cur == -* ]]; then + case "$group $action" in + "repo create") COMPREPLY=($(compgen -W "--section --desc --owner" -- "$cur")) ;; + "repo add-remote") COMPREPLY=($(compgen -W "--remote-name" -- "$cur")) ;; + esac + return + fi +} +complete -F _gitctl gitctl |
