=====Solaris 10 and zsh=====
For people like me who loves Solaris 10 and zsh, here a little file to put in your fpath. This file
provide - limited for the moment - completion for zones tools (zoneadm, zonecfg, zlogin).
====Demo====
% sudo zlogin -
option
-C -- console login
-E -- disable escape sequence character
-S -- safe login
-l -- username
% sudo zlogin -C
zone
databases public public-ejbca tools
====Code====
#compdef zoneadm zonecfg zlogin
_zones () {
case "$service" in
zoneadm) _zoneadm "$@";;
zonecfg) _zonecfg "$@";;
zlogin) _zlogin "$@";;
*) _message "Unknow service $service";;
esac
}
_zlogin () {
local -a zones
zones=($(zonelist))
_arguments \
'-l[username]:username:_users' \
'-C[console login]' \
'-S[safe login]' \
'-E[disable escape sequence character]' \
'*:zone:($zones)' && return
}
_zoneadm () {
local -a zones
zones=($(zonelist))
_arguments \
'-z[zone]:zone:($zones)' \
'*:command:(boot halt install list ready uninstall verify reboot)' && return
}
_zonecfg () {
local -a zones
zones=($(zonelist))
_arguments \
'-z[zone]:zone:($zones)' \
'-f[command file]:file:_files' && return
}
zonelist () {
local -a zones
# Fetch zone lists from /etc/zones/index
zones=(${${(a)"${(f)$(< /etc/zones/index)}"##\#*}//:*}) #" prevent vim become crazy
# Remove global zone from list "
zones[(r)global]=''
echo -n $zones
}
return 1
Feature version of this file will be available [[http://svn.asyd.net/svn/zsh/trunk/functions/_zones|here]]
~~DISCUSSION~~