1
0
mirror of synced 2026-02-08 08:41:28 +00:00
Files
xen-tools.xen-tools/misc/xm
steve 8008d92d0a 2005-12-23 01:21:22 by steve
Added more completion options.
2005-12-23 01:21:22 +00:00

74 lines
2.2 KiB
Plaintext

#
# /etc/bash_completion.d/xm
#
# Completion functions for Bash.
#
# Steve
# --
# http://www.steve.org.uk
#
# $Id: xm,v 1.2 2005-12-23 01:21:22 steve Exp $
#
_xm()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
#
# The basic options we'll complete.
#
opts="console create destroy help list pause reboot shutdown top unpause"
#
# Complete the arguments to some of the basic commands.
#
case "${prev}" in
console)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
create)
local names=$(for x in `ls -1 /etc/xen/*.cfg`; do echo ${x/\/etc\/xen\//} ; done )
COMPREPLY=( $(compgen -W "${names}" -- ${cur}) )
return 0
;;
destroy)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
pause)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
reboot)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
shutdown)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
unpause)
local running=$(for x in `xm list --long | grep \(name | grep -v Domain-0 | awk '{ print $2 }' | tr -d \)`; do echo ${x} ; done )
COMPREPLY=( $(compgen -W "${running}" -- ${cur}) )
return 0
;;
*)
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}
complete -F _xm xm