Skip to content

Add --completions flag to init command with automatic shell detection#8564

Merged
pelikhan merged 2 commits intomainfrom
copilot/add-completions-flag-to-init
Jan 2, 2026
Merged

Add --completions flag to init command with automatic shell detection#8564
pelikhan merged 2 commits intomainfrom
copilot/add-completions-flag-to-init

Conversation

Copy link
Contributor

Copilot AI commented Jan 2, 2026

The init command now supports automatic shell completion installation via --completions flag. Detects shell type from environment and installs appropriate completion configuration.

Changes

  • Shell detection (pkg/cli/shell_completion.go)

    • Prioritizes shell version variables (BASH_VERSION, ZSH_VERSION, FISH_VERSION)
    • Falls back to $SHELL environment variable
    • Handles Windows PowerShell detection
  • Installation handlers per shell type

    • Bash: ~/.bash_completion.d/gh-aw with sourcing instructions
    • Zsh: ~/.zsh/completions/_gh-aw with fpath configuration
    • Fish: ~/.config/fish/completions/gh-aw.fish (auto-loaded)
    • PowerShell: Profile configuration instructions
  • Integration into InitRepository

    • Added completions parameter to function signature
    • Uses Cobra's GenBashCompletion, GenZshCompletion, GenFishCompletion methods
    • Provides user instructions for enabling completions

Usage

gh aw init --completions

Output shows detected shell, installation path, and activation instructions:

ℹ Detected shell: bash
✓ Installed bash completion to: /home/user/.bash_completion.d/gh-aw

ℹ To enable completions, add the following to your ~/.bashrc:
  for f in ~/.bash_completion.d/*; do [ -f "$f" ] && source "$f"; done
Original prompt

Add a "--completions" flag to command "init" that configures cli completion for the current terminal environment.

Must detect automatically the current cli type (bash vs fish vs zsh vs ...) and configure it for completions


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add --completions flag to init command for CLI completion Add --completions flag to init command with automatic shell detection Jan 2, 2026
Copilot AI requested a review from pelikhan January 2, 2026 05:05
@pelikhan pelikhan marked this pull request as ready for review January 2, 2026 05:11
@pelikhan pelikhan merged commit 6aee057 into main Jan 2, 2026
4 checks passed
@pelikhan pelikhan deleted the copilot/add-completions-flag-to-init branch January 2, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants