CLI Bash Completions

I'm having trouble getting Bash completions working. When I try op <tab><tab>, I only see filename suggestions.

I have bash-completion installed via Homebrew.

$ brew info bash-completion
bash-completion: stable 1.3 (bottled)

I've tried adding source <(op completion bash) to my ~/.bash_profile and restarting iTerm but no luck.

By contrast, my Git completions are working just fine.

Any tips would be greatly appreciated!

op --version

1Password Version: 7.7
Extension Version:
OS Version: macOS 10.15.7
Sync Type: Not Provided


  • artem1Partem1P

    Team Member

    Hi @pauljmartinez,

    My apologies for the late response. I tried doing this on my machine as well and was not able to get it to work either. I am going to try to get this working and let you know as soon as I have a solution. We can then also update the instructions in our documentation to make sure it works.

    Thank you for bringing this to our attention!


  • Awesome, thanks!

  • artem1Partem1P

    Team Member

    You're welcome! We have opened to ticket to investigate this.

  • @artem1P Just wanted to check in and see if there was any news on this one.

  • ag_anaag_ana

    Team Member


    We don't have an update to share yet I am afraid :(

    ref: dev/b5/op#1053

  • @ag_ana It's all good, happy to wait for more awesomeness!

  • ag_yaronag_yaron

    Team Member


  • Michael_1PMichael_1P

    Team Member

    Hello @pauljmartinez

    I have a few follow-up questions to help us debug this. Can you share the results of this command?

    echo ${BASH_VERSION}

    I ask because I suspect that you are running bash-3.2. macOS still ships with a default bash version of 3.2 from 2007.

    The problem is that the programmable completion features of Bash have been extended significantly since version 3.2, and most completion scripts (including those for op) use these new features. This means that these completion scripts don’t work on Bash 3.2, which means that you miss out from the completion functionalities of many (but not all) commands, if you keep using the default macOS shell.

    However, op completion does work with a later version of bash that is available via brew (right now, that is v5.1.4). If you are using bash-3.2 and you are amenable to upgrading, then I have instructions for that:

    Upgrading macOS to the latest version of Bash using brew

    To upgrade the default shell of your macOS system to the latest version of Bash, you have to do three things:

    1. Install the latest version of Bash
    2. “Whitelist” new Bash as a login shell
    3. Set new Bash as the default shell

    Since you are using brew, I'll use that in these instructions:

    # 1. Install the latest version of Bash
    brew install bash
    # Verify the installation
    which -a bash
    # For me outputs:
    #    /usr/local/bin/bash
    #    /bin/bash
    # 2. Whitelist new Bash as a login shell
    sudo vim /etc/shells  # Or your editor of choice if not vim
    # Add the `/usr/local/bin/bash` shell as a new line to this file
    # 3. Set the default shell for your user
    chsh -s /usr/local/bin/bash

    It's also important to note that you are only changing the default shell for your user. Both versions are still available for all users and all scripts. If you normally start your scripts with the shebang line:

    echo ${BASH_VERSION}

    then you will still see version bash-3.2. I recommend that you use the following shebang line instead:

    #!/usr/bin/env bash
    echo ${BASH_VERSION

    This is a recommended format for a shebang line. It works by inspecting the PATH and using the first encountered bash executable as the interpreter for the script. If the directory of the new version is located before the directory of the old version in the PATH (which is the default), then the new version will be used, and the output of the script will be something like 5.1.2-release.

    I hope that this helps. Please feel free to write back with any further questions or clarifications.

  • @Michael_1P Thanks so much for reaching out. Your assumption is totally correct, I was running the default version of Bash. After upgrading via Homebrew I'm seeing all the Bash completion goodies.

    I hadn't realized that Apple had stopped updating Bash for so long. I guess because Bash moved to a GPLv3 license.

    Please consider my issue closed as upgrading Bash is a better move for me overall.

    $ which -a bash

    Original version.

    $ /bin/bash --version
    GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
    Copyright (C) 2007 Free Software Foundation, Inc.

    Upgraded version.

    $ /usr/local/bin/bash --version
    GNU bash, version 5.1.4(1)-release (x86_64-apple-darwin20.2.0)
    Copyright (C) 2020 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <>
    This is free software; you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

    Maximum happiness.

    $ op
    add         create      encode      list        signin      update
    completion  delete      forget      reactivate  signout
    confirm     edit        get         remove      suspend
  • Michael_1PMichael_1P

    Team Member

    Awesome, I'm so glad to hear that @pauljmartinez!

    If you ever have any further questions, don't hesitate to let us know.

  • Michael_1PMichael_1P

    Team Member

    @pauljmartinez One other task that I forgot to note is that you should upgrade your version of bash-completion as well!

    brew uninstall bash-completion
    brew install [email protected]

    and then ensure that these two lines are in your ~/.bash_profile:

    export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
    [[ -r "/usr/local/etc/profile.d/" ]] && . "/usr/local/etc/profile.d/"

    The bash-completion project recommends upgrading to version 2.x if you are using bash-4.1 or later.

    (These steps come from Daniel Weibel’s article Programmable Completion for Bash on macOS. Daniel wrote the book on programmable completion. If you're interested in what goes on under the hood, he's got detailed walkthroughs available as well.)

  • @Michael_1P Thanks for this info, I'll definitely update my system and check it out!

  • ag_yaronag_yaron

    Team Member

    On behalf of Michael_1P , you're most welcome @pauljmartinez :+1:

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file