mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-24 23:00:09 +00:00
Add plugin for LXD autocomplete (#7457)
This commit is contained in:
parent
6b5c872836
commit
f742baf73c
2 changed files with 35 additions and 0 deletions
9
plugins/lxd/README.md
Normal file
9
plugins/lxd/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# lxd
|
||||
|
||||
This plugin provides completion for [lxd](https://linuxcontainers.org/lxd/), as well as aliases
|
||||
for frequent lxc commands.
|
||||
|
||||
To use it add `lxd` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... lxd)
|
26
plugins/lxd/lxd.plugin.zsh
Normal file
26
plugins/lxd/lxd.plugin.zsh
Normal file
|
@ -0,0 +1,26 @@
|
|||
_lxc_get_command_list () {
|
||||
$_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
}
|
||||
|
||||
_lxc_get_subcommand_list () {
|
||||
$_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
|
||||
}
|
||||
|
||||
_lxc () {
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
_arguments \
|
||||
'1: :->command'\
|
||||
'*: :->args'
|
||||
|
||||
case $state in
|
||||
command)
|
||||
compadd $(_lxc_get_command_list)
|
||||
;;
|
||||
*)
|
||||
compadd $(_lxc_get_subcommand_list)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
compdef _lxc lxc
|
Loading…
Reference in a new issue