How to add bash command completion for Docker on Mac OS X?

前端 未结 8 416
渐次进展
渐次进展 2021-02-01 13:24

I am running docker and I want bash command completion for docker commands and parameters.

相关标签:
8条回答
  • 2021-02-01 13:47

    The stumbling point for me was that once you brew install bash-competion, you have to add few lines in your .bash_profile to load it once you launch Terminal:

    if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
    fi
    

    Source: http://davidalger.com/development/bash-completion-on-os-x-with-brew/

    Because I haven't found anywhere a step by step documentation, I've made a quick script to install homebrew, bash-completion and eventually the completion scripts for docker. https://github.com/HypnoTheNomad/docker-bash-completion-macos-brew

    0 讨论(0)
  • 2021-02-01 13:51

    The official Docker site has a section for Command-line completion, and for Mac to:

    https://docs.docker.com/compose/completion/#mac

    Helped for me with Homebrew:

    brew install bash-completion
    

    After the installation, Brew displays the installation path. From documentation is correct for me:

    /usr/local/etc/bash_completion.d/

    Run the script:

    sudo curl -L https://raw.githubusercontent.com/docker/compose/1.25.4/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
    

    Open and add following in the end of your file ~/.bash_profile:

    if [ -f $(brew --prefix)/etc/bash_completion ]; then
     . $(brew --prefix)/etc/bash_completion
     fi
    

    Restart terminal. It's all.

    0 讨论(0)
提交回复
热议问题