mirror of
https://github.com/linka-cloud/d2vm.git
synced 2024-11-29 11:06:24 +00:00
fix zsh completion not working with source
README.md: add shell completion installation instructions Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
parent
7f3b3a859d
commit
f1557d104d
17
README.md
17
README.md
@ -75,6 +75,23 @@ which d2vm
|
|||||||
/go/bin/d2vm
|
/go/bin/d2vm
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Generate shell completion
|
||||||
|
|
||||||
|
The *d2vm* program supports shell completion for *bash*, *zsh* and *fish*.
|
||||||
|
|
||||||
|
It can be enabled by running the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source <(d2vm completion $(basename $SHELL))
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you can install the completion file in the shell completion directory by following the instructions:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
d2vm completion $(basename $SHELL) --help
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Converting an existing Docker Image to VM image:
|
### Converting an existing Docker Image to VM image:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -56,6 +56,12 @@ var (
|
|||||||
logrus.SetLevel(logrus.TraceLevel)
|
logrus.SetLevel(logrus.TraceLevel)
|
||||||
}
|
}
|
||||||
exec.SetDebug(verbose)
|
exec.SetDebug(verbose)
|
||||||
|
|
||||||
|
// make the zsh completion work when sourced with `source <(d2vm completion zsh)`
|
||||||
|
if cmd.Name() == "zsh" && cmd.Parent() != nil && cmd.Parent().Name() == "completion" {
|
||||||
|
zshHead := fmt.Sprintf("#compdef %[1]s\ncompdef _%[1]s %[1]s\n", cmd.Root().Name())
|
||||||
|
cmd.OutOrStdout().Write([]byte(zshHead))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user