lxd.plugin.zsh 548 B

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