Skip to content

feat(cli): add shell completion for bash (fix #843)#2934

Open
haroldfabla2-hue wants to merge 1 commit intoopenai:mainfrom
haroldfabla2-hue:feat/shell-completion
Open

feat(cli): add shell completion for bash (fix #843)#2934
haroldfabla2-hue wants to merge 1 commit intoopenai:mainfrom
haroldfabla2-hue:feat/shell-completion

Conversation

@haroldfabla2-hue
Copy link

Summary

Added bash shell completion script for the OpenAI CLI.

Changes

  • Created helpers/shell-completion.bash with bash completion support
  • Supports all CLI flags: api_base, api_key, api_type, azure_ad_token, azure_endpoint, organization, proxy, verbose, version

Usage

To use the completion, source the script:

source helpers/shell-completion.bash

Or copy it to your bash completion directory:

cp helpers/shell-completion.bash /etc/bash_completion.d/openai

This resolves issue #843: Add shell auto completion for different shells.

- Added bash completion script for openai CLI
- Supports all CLI flags: api_base, api_key, api_type, azure_*, organization, proxy, verbose, version
@haroldfabla2-hue haroldfabla2-hue requested a review from a team as a code owner March 6, 2026 15:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdf13bda24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"

opts="api_base api_key api_type azure_ad_token azure_endpoint help organization proxy verbose version"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Emit real CLI flags in completion candidates

The completion list is built from api_base, api_key, etc., but the CLI parser actually accepts hyphenated, prefixed flags like --api-base, --api-key, --azure-endpoint (src/openai/cli/_cli.py, _build_parser). Because Bash completion matches the current token prefix, a common flow like typing openai --a<Tab> yields no matches, and any suggestions that do appear are not valid command-line flags, so the new completion script is effectively broken for top-level options.

Useful? React with 👍 / 👎.

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.

1 participant