Add command-line completion (bash/zsh/fish) including key lookup #2

Closed
opened 2026-05-09 12:45:50 +02:00 by heiko · 0 comments
Owner

Feature

Provide shell completion for gpg-publish that covers:

  • Flags: --check, --verbose, --nsupdate, --ttl, --domain, --label-only, --version
  • Target argument: Complete email addresses from the private GPG keyring (gpg --list-keys --with-colons to extract UIDs), file paths, and the literal - for stdin.

Approach options

  1. Built-in completion output — Add a --completion bash|zsh|fish flag that emits the shell-specific completion script (like kubectl completion bash).
  2. External completion scripts — Ship static completion files in a completions/ directory.

Option 1 is more maintainable since the completion stays in sync with the actual flags.

Key completion

For the target argument, offer completions from:

gpg --list-keys --with-colons 2>/dev/null | awk -F: '/^uid:/ {print $10}' | grep -oP '<\K[^>]+'

This lists all email addresses in the user's public keyring.

Shells to support

  • bash (most common on Linux servers)
  • zsh (default on macOS)
  • fish (nice to have)
## Feature Provide shell completion for `gpg-publish` that covers: - **Flags:** `--check`, `--verbose`, `--nsupdate`, `--ttl`, `--domain`, `--label-only`, `--version` - **Target argument:** Complete email addresses from the private GPG keyring (`gpg --list-keys --with-colons` to extract UIDs), file paths, and the literal `-` for stdin. ## Approach options 1. **Built-in completion output** — Add a `--completion bash|zsh|fish` flag that emits the shell-specific completion script (like `kubectl completion bash`). 2. **External completion scripts** — Ship static completion files in a `completions/` directory. Option 1 is more maintainable since the completion stays in sync with the actual flags. ## Key completion For the target argument, offer completions from: ```bash gpg --list-keys --with-colons 2>/dev/null | awk -F: '/^uid:/ {print $10}' | grep -oP '<\K[^>]+' ``` This lists all email addresses in the user's public keyring. ## Shells to support - bash (most common on Linux servers) - zsh (default on macOS) - fish (nice to have)
heiko closed this issue 2026-05-09 20:49:06 +02:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
heiko/gpg-publish#2
No description provided.