Machine: 安装 bash 完成脚本文档

创建于 2015-12-08  ·  15评论  ·  资料来源: docker/machine

你好,
centos7 的(https://docs.docker.com/machine/install-machine/)文档似乎是错误的。
bash_completion 默认不安装,所以必须指定。
仍然有错误-bash:__docker-machine-ps1:找不到命令
问候

kindocs

最有用的评论

如果您有错误__docker_machine_ps1: command not found ,这意味着您需要告诉您的安装程序在哪里可以找到您之前下载的文件docker-machine-prompt.bash 。 例如在 .bashrc 中,在 PS1 行之前:

source /etc/bash_completion.d/docker-machine-prompt.bash

所有15条评论

这是因为该函数实际上称为“__docker_machine_ps1”。

现在工作正常。
干得好:+1:

Mac和Linux都存在同样的问题,运行zsh

$(__docker_machine_ps1)
zsh: command not found: __docker_machine_ps1
 gilani<strong i="5">@debris</strong>  /etc/bash_completion.d  bash
gilani<strong i="6">@debris</strong>:/etc/bash_completion.d$ $(__docker_machine_ps1)
__docker_machine_ps1: command not found
gilani<strong i="7">@debris</strong>:/etc/bash_completion.d$ exit
exit
 ✘ gilani<strong i="8">@debris</strong>  /etc/bash_completion.d  $(__docker_machine_ps1)
zsh: command not found: __docker_machine_ps1

也检查了 bash,在那里也不起作用。 Linux 基于 Ubuntu 14.04。

有同样的问题:
__docker_machine_ps1: command not found
在 Ubuntu 16.04 上

Debian 7.5
__docker_machine_ps1:找不到命令

我刚刚在我的 etc/bash_completion.d/docker 文件中将其注释掉:
# PS1='[\u@\h \W$(__docker_machine_ps1)]\$ '
否则工作起来很烦人

如果您有错误__docker_machine_ps1: command not found ,这意味着您需要告诉您的安装程序在哪里可以找到您之前下载的文件docker-machine-prompt.bash 。 例如在 .bashrc 中,在 PS1 行之前:

source /etc/bash_completion.d/docker-machine-prompt.bash

我在 Ubuntu 16.04 上遇到了同样的问题,我试图在 ~/.bashrc 上声明变量:

__docker_machine_ps1=source '/etc/bash_completion.d/docker-machine-prompt.bash'

可能我没有做正确的方式,但我不知道该怎么做。

我希望有人帮助我,谢谢!

@nickdgriffin实际上,我有,并且收到此错误:

bash:__docker_machine_ps1:找不到命令

这是在文档中: https: //docs.docker.com/machine/install-machine/#installing -bash-completion-scripts。 尝试这样做:

sudo su
cd /etc/bash_completion.d/
wget https://raw.githubusercontent.com/docker/machine/v0.11.0/contrib/completion/bash/docker-machine-prompt.bash
wget https://raw.githubusercontent.com/docker/machine/v0.11.0/contrib/completion/bash/docker-machine-wrapper.bash
wget https://raw.githubusercontent.com/docker/machine/v0.11.0/contrib/completion/bash/docker-machine.bash
exit
# and reload the terminal

我正在使用 macOS Sierra v10.12.6。

我通过以下步骤添加了 Bash Completion 感谢@rubyconvict

  • 安装 Bash 完成脚本。 将以下 URL 中的版本替换为最新的 Docker 机器版本https://github.com/docker/machine/releases。

    • 注意:如果 Bash Completion 已经与 Homebrew 一起安装(检查brew list bash-completion ),则使用/etc/bash_completion.d/而不是下面的/usr/local/etc/bash_completion.d/

      brew install wget sudo su cd /usr/local/etc/bash_completion.d/ wget https://raw.githubusercontent.com/docker/machine/v0.12.2/contrib/completion/bash/docker-machine-prompt.bash wget https://raw.githubusercontent.com/docker/machine/v0.12.2/contrib/completion/bash/docker-machine-wrapper.bash wget https://raw.githubusercontent.com/docker/machine/v0.12.2/contrib/completion/bash/docker-machine.bash exit

  • 附加到~/.bashrc
    echo 'source /usr/local/etc/bash_completion.d/docker-machine-prompt.bash' >> ~/.bashrc; echo 'source /usr/local/etc/bash_completion.d/docker-machine-wrapper.bash' >> ~/.bashrc; echo 'source /usr/local/etc/bash_completion.d/docker-machine.bash' >> ~/.bashrc; echo 'PS1="[\u@\h \W$(__docker_machine_ps1)]\$ "' >> ~/.bashrc; source ~/.bashrc; cat ~/.bashrc;

我遇到了,我解决了。
我认为您的脚本名为“docker-machine-prompt.bash”,这是绝对错误的。只需使用 x 权限将其重命名为另一个。
这些文件确实让我很困惑

如果您有错误__docker_machine_ps1: command not found ,这意味着您需要告诉您的安装程序在哪里可以找到您之前下载的文件docker-machine-prompt.bash 。 例如在 .bashrc 中,在 PS1 行之前:

source /etc/bash_completion.d/docker-machine-prompt.bash

谢谢它的作品!

此页面是否有帮助?
0 / 5 - 0 等级