Skip to content

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

Closed as not planned

Description

@gitmpr

Generating shell completion scripts by introspecting the Go code should be fairly straightforward, especially using popular libraries like Cobra. It would be great to have
source <(opencode completions $SHELL)
for easy shell integration. I’d be happy to help create a PR for this if core feature contributions weren’t restricted by the README guidelines.

Activity

  1. self-assigned this
    on Aug 4, 2025
  2. strk commented on Nov 13, 2025

    @strk

    Just a note: I didn't find this issue because I searched for "tab", given mine was the second duplicated issue maybe the title of this one could be updated to also mention "TAB" as I guess all cli completions are implemented that way (or at least most commonly) ?

  3. changed the title [-]Feature request: cli completions for bash, fish, and zsh[/-] [+]Feature request: cli tab completions for bash, fish, and zsh[/+] on Nov 13, 2025
  4. rekram1-node commented on Nov 13, 2025

    @rekram1-node
    Collaborator

    Sure thing added it, glad the bot spotted the dup

  5. lcdss commented on Mar 11, 2026

    @lcdss

    Any progress on this? It would be great if we had fish/nushell completions as well.

  6. nbonfire commented on Mar 19, 2026

    @nbonfire

    this is far from ideal but here's a basic opencode.fish for completions using the existing yargs completions:

    https://gist.github.com/nbonfire/3d1a6cd407bce53b7d750aaec20bcda9

    # Disable default file completion unless yargs gives nothing
    complete -c opencode -f
    
    function __opencode_yargs_completions
        # Tokens up to cursor (excluding current token)
        set -l tokens (commandline -opc)
    
        # Current token (may be empty or '-')
        set -l cur (commandline -ct)
    
        # If there *is* a current token, append it
        if test -n "$cur"
            set tokens $tokens $cur
        end
    
        opencode --get-yargs-completions $tokens 2>/dev/null
    end
    
    complete -c opencode -f -k -a "(__opencode_yargs_completions)"
    complete -c opencode --force-files
    
  7. davidebriani commented on Mar 25, 2026

    @davidebriani

    Here are completions for Fish that correctly handle subcommands and file completions.

    # Installation: Save to ~/.config/fish/completions/opencode.fish
    
    function __opencode_completions
        set -l args (commandline -opc)
        set -e args[1]
        set -l results (opencode --get-yargs-completions $args 2>/dev/null | grep -v '^\$0$')
        if test (count $results) -eq 0
            __fish_complete_path (commandline -ct)
        else
            printf '%s\n' $results
        end
    end
    
    complete -c opencode -f -a '(__opencode_completions)'
  8. PEMessage commented on Apr 2, 2026

    @PEMessage
  9. jkonecny12 commented on May 7, 2026

    @jkonecny12

    Hi, I've tried to add new implementation for this in #26193 which is using existing dynamic solution.

    And yeah, it's slower but hopefully will be easier to manage.

    My experience with ZSH is limited so if someone wants to try feel free to verify. I'm Fish shell user myself.

  10. wakamori commented on May 8, 2026

    @wakamori

    I'd like to add dynamic value completion for session IDs so that pressing suggests actual session IDs from the local database. This would apply to all places that accept a session ID:

    • opencode -s <TAB> / opencode --session <TAB>
    • opencode session delete <TAB>
    • opencode export <TAB>

    This could also extend to other dynamic values like --model and --agent.

    Questions:

    1. Would this be accepted as a contribution?
    2. Should it build on feat(cli):fish and zsh shell completion #26193's architecture or target dev independently?

    Happy to implement once there's alignment on the approach.

  11. added a commit that references this issue on Jun 5, 2026
    495237f
  12. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  13. RafalSkolasinski commented on Aug 20, 2026

    @RafalSkolasinski

    a bit disappointing to see this closed

  14. Luka-Hanzek commented on Sep 1, 2026

    @Luka-Hanzek

    a bit disappointing to see this closed

    I thought this was a bug until I found this... how is this not implemented from the beginning...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions