Skip to content

feat: add shell tab completion for bash, zsh, and fish#6

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-tab-command-suggestion
Draft

feat: add shell tab completion for bash, zsh, and fish#6
Copilot wants to merge 3 commits intomainfrom
copilot/add-tab-command-suggestion

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

No tab completion existed for the halo CLI. This adds a halo completion command that emits shell hook scripts and handles the inline completion callback shells invoke on every Tab press.

New: halo completion command

  • halo completion bash|zsh|fish — prints a shell-specific completion hook script to stdout; users source it in their rc file or drop it into the fish completions directory
  • halo completion -- <words…> — the internal callback invoked by the hook on every Tab; returns newline-separated candidates to stdout

Completion logic (src/commands/completion/index.ts)

  • Static TOP_LEVEL_COMMANDS + SUBCOMMANDS maps covering all 12 command areas and their full subcommand trees, including two-level namespaces (auth profile, comment reply)
  • computeCompletions(words) handles both invocation modes:
    • bash/zsh: reads COMP_LINE + COMP_POINT env vars for cursor-aware tokenization
    • fish: uses the explicit word array passed by the hook
  • Partial-word prefix filtering; bails cleanly when context contains option flags or exceeds supported nesting depth

Setup

# Bash — add to ~/.bashrc
eval "$(halo completion bash)"

# Zsh — add to ~/.zshrc
eval "$(halo completion zsh)"

# Fish
halo completion fish > ~/.config/fish/completions/halo.fish

After sourcing, halo po<TAB>post; halo post <TAB>list get create update delete open import-json export-json.

Original prompt

This section details on the original issue you should resolve

<issue_title>期望支持按 tab 进行命令联想</issue_title>
<issue_description>类似于 npm 一样,输入 npm in 时按下 tab,会对所有可用的命令进行联想然后列出,方便使用。

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 19, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Co-authored-by: ruibaby <21301288+ruibaby@users.noreply.github.com>
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Mar 19, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Co-authored-by: ruibaby <21301288+ruibaby@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for command suggestions using tab key feat: add shell tab completion for bash, zsh, and fish Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

期望支持按 tab 进行命令联想

2 participants