Skip to content

feat: add fish shell tab completions#23263

Open
nitishagar wants to merge 1 commit intoanomalyco:devfrom
nitishagar:contrib/issue-1515
Open

feat: add fish shell tab completions#23263
nitishagar wants to merge 1 commit intoanomalyco:devfrom
nitishagar:contrib/issue-1515

Conversation

@nitishagar
Copy link
Copy Markdown

Issue for this PR

Closes #1515

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds fish shell tab completion support. Bash/zsh completions already work via yargs' built-in .completion() method, but fish uses a completely different format (complete -c opencode ...) that yargs can't generate.

Changes:

  • New packages/opencode/src/cli/cmd/completion.ts with a generateFishCompletions() function that outputs a static fish completion script covering all commands, subcommands, options, and choices
  • Pre-parse interception in index.ts: when opencode completion --shell fish is invoked, the fish script is output before yargs processes the args. Existing bash/zsh behavior is completely untouched
  • Updated nix/opencode.nix to install fish completions alongside bash/zsh

Usage:

opencode completion              # bash/zsh (unchanged)
opencode completion --shell fish # fish (new)

The fish script uses standard fish patterns (__fish_seen_subcommand_from, set -l subcommand lists) to gate completions properly for nested subcommands like opencode debug lsp diagnostics.

How did you verify your code works?

  • Ran bun run typecheck — no errors in changed files
  • Verified fish output via bun -e "import { generateFishCompletions } from './packages/opencode/src/cli/cmd/completion.ts'; console.log(generateFishCompletions())" — produces 237 lines of valid fish completion syntax
  • Verified existing .completion() call and --get-yargs-completions mechanism are untouched

Screenshots / recordings

N/A — CLI feature, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@nitishagar
Copy link
Copy Markdown
Author

CI check-duplicates timed out on first run — not related to code changes. Requesting re-run.

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.

Feature request: cli tab completions for bash, fish, and zsh

1 participant