glpkg supports shell completion for bash and zsh, providing tab-completion for commands, options, and arguments.
- Completion powered by argcomplete
- Supports bash and zsh shells
- Provides tab-completion for subcommands, flags, and option values
Use the built-in completion installer:
# For Bash
glpkg --install-completion bash
# For Zsh
glpkg --install-completion zshFollow the activation instructions printed after installation.
-
Generate the completion script:
glpkg --install-completion bash
Or manually create the file at
~/.bash_completion.d/glpkg -
Add to your
~/.bashrc:source ~/.bash_completion.d/glpkg
-
Reload your shell:
source ~/.bashrc
Or restart your terminal.
-
Generate the completion script:
glpkg --install-completion zsh
Or manually create the file at
~/.zsh/completion/_glpkg -
Add to your
~/.zshrc(beforecompinit):fpath=(~/.zsh/completion $fpath) -
Reload completions:
autoload -Uz compinit && compinitOr restart your terminal.
Once installed, use Tab to complete commands and options:
# Show available commands
glpkg <Tab>
# Show options for upload command
glpkg upload --<Tab>
# Complete long option names
glpkg upload --pack<Tab> # completes to --package-nameTest that completion is working:
- Open a new terminal or reload your shell
- Type
glpkgfollowed by a space and press Tab twice - You should see available commands and options
If completion works, you'll see suggestions like:
upload --help --verbose --json-output
-
Verify installation: Check that the completion script exists
# Bash cat ~/.bash_completion.d/glpkg # Zsh cat ~/.zsh/completion/_glpkg
-
Verify shell configuration: Ensure your shell config sources the completion
# Check bashrc grep -n "bash_completion" ~/.bashrc # Check zshrc grep -n "completion" ~/.zshrc
-
Restart shell: Close and reopen your terminal, or source your config file
If you encounter permission errors during installation:
# Create directory with appropriate permissions
mkdir -p ~/.bash_completion.d
chmod 755 ~/.bash_completion.d
# Or for zsh
mkdir -p ~/.zsh/completion
chmod 755 ~/.zsh/completionThen re-run the installation command.
Ensure fpath is updated before compinit in your .zshrc:
# This must come BEFORE compinit
fpath=(~/.zsh/completion $fpath)
# Then initialize completions
autoload -Uz compinit && compinitIf you've modified your .zshrc, rebuild the completion cache:
rm -f ~/.zcompdump
compinit- Implementation:
src/glpkg/cli/completion.py - Bash completion path:
~/.bash_completion.d/glpkg - Zsh completion path:
~/.zsh/completion/_glpkg - Library: argcomplete for completion generation