|
| 1 | +<!--[metadata]> |
| 2 | ++++ |
| 3 | +title = "Command-line Completion" |
| 4 | +description = "Install Machine command-line completion" |
| 5 | +keywords = ["machine, docker, orchestration, cli, reference"] |
| 6 | +[menu.main] |
| 7 | +parent="smn_workw_machine" |
| 8 | +weight=10 |
| 9 | ++++ |
| 10 | +<![end-metadata]--> |
| 11 | + |
| 12 | +# Command-line Completion |
| 13 | + |
| 14 | +Docker Machine comes with [command completion](http://en.wikipedia.org/wiki/Command-line_completion) |
| 15 | +for the bash shell. |
| 16 | + |
| 17 | +## Installing Command Completion |
| 18 | + |
| 19 | +### Bash |
| 20 | + |
| 21 | +Make sure bash completion is installed. If you use a current Linux in a non-minimal installation, bash completion should be available. |
| 22 | +On a Mac, install with `brew install bash-completion` |
| 23 | + |
| 24 | +Place the completion scripts in `/etc/bash_completion.d/` (`` `brew --prefix`/etc/bash_completion.d/`` on a Mac), using e.g. |
| 25 | + |
| 26 | + files=(docker-machine docker-machine-wrapper docker-machine-prompt) |
| 27 | + for f in "${files[@]}"; do |
| 28 | + curl -L https://raw.githubusercontent.com/docker/machine/v$(docker-machine --version | awk 'NR==1{print $(NF-1)}')/contrib/completion/bash/$f.bash > `brew --prefix`/etc/bash_completion.d/$f |
| 29 | + done |
| 30 | + |
| 31 | +Completion will be available upon next login. |
| 32 | + |
| 33 | +<!-- |
| 34 | +### Zsh |
| 35 | +
|
| 36 | +**Note: there does not seem to be any Zsh completion file yet, but when there is, documentation could look like this.** |
| 37 | +
|
| 38 | +Place the completion scripts in your `/path/to/zsh/completion`, using e.g. `~/.zsh/completion/` |
| 39 | +
|
| 40 | + mkdir -p ~/.zsh/completion |
| 41 | + files=(docker-machine docker-machine-wrapper docker-machine-prompt) |
| 42 | + for f in "${files[@]}"; do |
| 43 | + curl -L https://raw.githubusercontent.com/docker/machine/v$(docker-machine --version | awk 'NR==1{print $(NF-1)}')/contrib/completion/zsh/$f > ~/.zsh/completion/_$f |
| 44 | + done |
| 45 | +
|
| 46 | +Include the directory in your `$fpath`, e.g. by adding in `~/.zshrc` |
| 47 | +
|
| 48 | + fpath=(~/.zsh/completion $fpath) |
| 49 | +
|
| 50 | +Make sure `compinit` is loaded or do it by adding in `~/.zshrc` |
| 51 | +
|
| 52 | + autoload -Uz compinit && compinit -i |
| 53 | +
|
| 54 | +Then reload your shell |
| 55 | +
|
| 56 | + exec $SHELL -l |
| 57 | +
|
| 58 | +--> |
| 59 | + |
| 60 | +## Available completions |
| 61 | + |
| 62 | +**TODO** |
0 commit comments