Machine: Installing bash completion scripts documentation

Created on 8 Dec 2015  Â·  15Comments  Â·  Source: docker/machine

Hi,
documentation for (https://docs.docker.com/machine/install-machine/) for centos7 seems to be wrong.
bash_completion is not installed by default , so it's has to be specifiied.
stiil have error -bash: __docker-machine-ps1: command not found
Regards

kindocs

Most helpful comment

If you have the error __docker_machine_ps1: command not found, it means you need to tell your setup where it can find the file docker-machine-prompt.bash that you previously downloaded. For example in .bashrc, before the PS1 lines:

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

All 15 comments

It's because the function is actually called "__docker_machine_ps1".

working fine now .
Good job :+1:

Same issue here with both Mac and Linux, running zsh

$(__docker_machine_ps1)
zsh: command not found: __docker_machine_ps1
 gilani@debris î‚° /etc/bash_completion.d î‚° bash
gilani@debris:/etc/bash_completion.d$ $(__docker_machine_ps1)
__docker_machine_ps1: command not found
gilani@debris:/etc/bash_completion.d$ exit
exit
 ✘ gilani@debris  /etc/bash_completion.d  $(__docker_machine_ps1)
zsh: command not found: __docker_machine_ps1

Checked on bash too, doesn't work there either. Linux is Ubuntu 14.04 based.

having the same issue:
__docker_machine_ps1: command not found
on Ubuntu 16.04

Debian 7.5
__docker_machine_ps1: command not found

I've just commented it out in my etc/bash_completion.d/docker file:
# PS1='[\u@\h \W$(__docker_machine_ps1)]\$ '
otherwise it was pretty annoying to work with

If you have the error __docker_machine_ps1: command not found, it means you need to tell your setup where it can find the file docker-machine-prompt.bash that you previously downloaded. For example in .bashrc, before the PS1 lines:

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

I'm having the same problem on Ubuntu 16.04 and I tried to declare the variable on ~/.bashrc:

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

Probably I'm not doing the rigth way, but I don't know how to do this.

I hope somebody help me, thanks!

@nickdgriffin Actually, I have that, and am getting this error:

bash: __docker_machine_ps1: command not found

This is in the docs: https://docs.docker.com/machine/install-machine/#installing-bash-completion-scripts. Try doing this:

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

I'm using macOS Sierra v10.12.6.

I added Bash Completion with the following steps thanks for @rubyconvict:

  • Install Bash Completion scripts. Replace version in URLs below with latest Docker Machine version https://github.com/docker/machine/releases.

    • Note: If Bash Completion already installed with Homebrew (check with brew list bash-completion) then use /etc/bash_completion.d/ instead of /usr/local/etc/bash_completion.d/ below:

      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

  • Append to ~/.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;

i met it ,and i solved it.
i think your script's named "docker-machine-prompt.bash" ,it's absolutely wrong .just rename it to the other with x premission.
the documents confused me indeed

If you have the error __docker_machine_ps1: command not found, it means you need to tell your setup where it can find the file docker-machine-prompt.bash that you previously downloaded. For example in .bashrc, before the PS1 lines:

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

Thanks it works!

Was this page helpful?
0 / 5 - 0 ratings