Hi, I created a ZSH completion script for most of LXC tools (using LXC 0.6.5). I am not a zsh guru, so maybe I did it wrong.
Anyway, at first I only wanted to complete the name of the containers based on the content of /var/lib/lxc, but then I decided to write the whole thing. It should be installed in /usr/share/zsh/site-functions for system-wide installation. Alternatively if you want to add it for only your user, you will have to modify the "fpath" variable before loading compinit in your .zshrc. Eg: fpath=($fpath $HOME/.zsh.comp.d) # _lxc is in the .zsh.comp.d directory autoload -U compinit compinit I hope this is useful. Vincent.
#compdef lxc-start lxc-stop lxc-console lxc-restart lxc-create lxc-destroy lxc-monitor lxc-cgroup lxc-checkpoint lxc-execute lxc-freeze lxc-unfreeze lxc-info lxc-netstat lxc-ps lxc-wait _lxc_containers() { local -a containers containers=( $(/bin/ls /var/lib/lxc) ) compadd "$@" -a containers } _lxc_common_opts=( '(-o --logfile)'{-o,--logfile=}'[Output log to FILE instead of stderr]:logfile:_files' '(-l --logpriority)'{-l,--logpriority=}'[Set log priority to LEVEL]:level:' '(-q --quiet)'{-q,--quiet}'[Dont produce any output]' '(-h --help)'{-h,--help}'[Help list]' '--usage[Give a short usage message]' ) _lxc_name_opt=( '(-n --name)'{-n,--name=}'[Name of the container]:name:_lxc_containers' ) _lxc_start_opts=( '(-d --daemon)'{-d,--daemon}'[Daemonize the container]' '(-f --rcfile)'{-f,--rcfile=}'[Load configuration file FILE]:config:_files' '(-s --define)'{-s,--define}'[Assign VAL to configuration variable KEY]' ) _lxc_console_opts=( '(-t --tty)'{-t,--tty=}'[Console TTY number]' '(-e --escape)'{-e,--escape=}'[Prefix for escape command]' ) _lxc_restart_opts=( '(-p --pause)'{-p,--pause}'[Do not release the container after the restart]' '(-d --directory)'{-d,--directory=}'[Name of statefile]:name:_files' '(-f --rcfile)'{-f,--rcfile=}'[Load configuration file FILE]:config:_files' '(-s --define)'{-s,--define}'[Assign VAL to configuration variable KEY]' ) _lxc_create_opts=( '(-n --name)'{-n,--name=}'[Name of the container]:name' '(-f --config)'{-f,--config=}'[Load configuration file FILE]:config:_files' '(-t --template)'{-t,--template=}'[LXC template script]:tpl:_files' '(-h --help)'{-h,--help}'[Help list]' ) _lxc_checkpoint_opts=( '(-k --kill)'{-k,--kill}'[Stop the container after the checkpoint]' '(-p --pause)'{-p,--pause}'[Dont unfreeze the container after the checkpoint]' '(-d --directory)'{-d,--directory=}'[Where to store the statefile]:statefile:_files' ) _lxc_execute_opts=( '(-f --rcfile)'{-f,--rcfile=}'[Load configuration file FILE]:config:_files' '(-s --define)'{-s,--define}'[Assign VAL to configuration variable KEY]' ) _lxc_ps_opts=( '--help[Display the help]' '--usage[Display the command usage]' '--name[Display processes related to given containers. Containers are identified by a comma separated list of their names.]' '--lxc[Display processes related to all LXC containers]' ) _lxc_wait_opts=( '(-s --state)'{-s,--state=}'[ORed states to wait for: STOPPED, STARTING, RUNNING, STOPPING, ABORTING, FREEZING, FROZEN]:state' ) # Dispatcher _lxc() { case "$service" in lxc-start) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_start_op...@]" \ "$_lxc_common_op...@]" ;; lxc-stop) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" \ ;; lxc-console) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_console_op...@]" \ "$_lxc_common_op...@]" ;; lxc-restart) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_restart_op...@]" \ "$_lxc_common_op...@]" ;; lxc-create) _arguments -s : "$_lxc_create_op...@]" ;; lxc-destroy) _arguments -s : "$_lxc_name_o...@]" ;; lxc-monitor) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" ;; lxc-cgroup) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" ;; lxc-checkpoint) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_checkpoint_op...@]" \ "$_lxc_common_op...@]" ;; lxc-execute) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_execute_op...@]" \ "$_lxc_common_op...@]" ;; lxc-freeze) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" ;; lxc-unfreeze) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" ;; lxc-info) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_common_op...@]" ;; lxc-netstat) _arguments -s : "$_lxc_name_o...@]" ;; lxc-ps) _arguments -s : "$_lxc_ps_op...@]" ;; lxc-wait) _arguments -s : \ "$_lxc_name_o...@]" \ "$_lxc_wait_op...@]" ;; *) return 1 esac } _lxc "$@"
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev
_______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel