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

前端 未结 8 530
渐次进展
渐次进展 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:36

    If you have already homebrew bash-completion installed just install the docker completion script into the bash_completion.d

    curl -XGET https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker > $(brew --prefix)/etc/bash_completion.d/docker
    

    Note: If you do not have homebrew bash-completion installed, follow these instructions to install it before you execute the line above.

    Note: the completion depends on some functions defined in debian bash-completion. Therefore, just sourcing the docker completion script as described in completion/bash/docker may not work. If you try to complete docker run (by hitting TAB) you may get an error like __ltrim_colon_completions: command not found. This could mean that you have not installed the bash-completion scripts.

提交回复
热议问题