lxd.plugin.zsh
548 bytes
1_lxc_get_command_list () {
2 $_comp_command1 | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
3}
4
5_lxc_get_subcommand_list () {
6 $_comp_command1 ${words[2]} | sed "1,/Available Commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
7}
8
9_lxc () {
10 local curcontext="$curcontext" state line
11 typeset -A opt_args
12 _arguments \
13 '1: :->command'\
14 '*: :->args'
15
16 case $state in
17 command)
18 compadd $(_lxc_get_command_list)
19 ;;
20 *)
21 compadd $(_lxc_get_subcommand_list)
22 ;;
23 esac
24}
25
26compdef _lxc lxc