forked from OpenIndiana/openindiana-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zones
78 lines (68 loc) · 2.38 KB
/
zones
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# OpenIndiana zones(5) completion -*- shell-script -*-
# ------------------------------------------------------------------------------
# Copyright (c) 2013, Jonathan Perkin <[email protected]>
# Copyright (c) 2018, Michal Nowak <[email protected]>
_zlogin()
{
local cur prev line
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
line="${COMP_LINE}"
# zlogin [-dCEQ] [-e c] [-l username] zonename
# zlogin [-nEQS] [-e c] [-l username] zonename utility [argument]...
local opts="-E -Q -e -l"
local opts_interactive="-d -C"
local opts_util="-n -S"
if [[ "${cur}" == -* ]]
then
case "${line}" in
*\ -n\ *|*\ -S\ *)
COMPREPLY=( $(compgen -W "${opts} ${opts_util}" -- "${cur}") )
;;
*\ -d\ *|*\ -C\ *)
COMPREPLY=( $(compgen -W "${opts} ${opts_interactive}" -- "${cur}") )
;;
*)
COMPREPLY=( $(compgen -W "${opts} ${opts_util} ${opts_interactive}" -- "${cur}") )
;;
esac
else
# Provide running zone names
local zones=$(zoneadm list -n)
COMPREPLY=( $(compgen -W "${zones}" -- ${cur}) )
fi
}
_dash_z_zone()
{
local cur prev
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ${prev} =~ "-z" ]]; then
local zones="$(zoneadm list -n $*)"
COMPREPLY=( $(compgen -W "${zones}" -- ${cur}) )
fi
}
_dash_z_zone_running() { _dash_z_zone; }
_dash_z_zone_configured() { _dash_z_zone -c; }
# Many illumos utilities are zone-aware through the -z option
complete -F _zlogin zlogin
complete -F _dash_z_zone_running allocate
complete -F _dash_z_zone_running deallocate
complete -F _dash_z_zone_running ipfs
complete -F _dash_z_zone_running ipfstat
complete -F _dash_z_zone_running ipmon
complete -F _dash_z_zone_running ipnat
complete -F _dash_z_zone_running ippool
complete -F _dash_z_zone_running pgrep
complete -F _dash_z_zone_running pkill
complete -F _dash_z_zone_running ps
complete -F _dash_z_zone_running psrset
complete -F _dash_z_zone_running ptree
complete -F _dash_z_zone_running svccfg
complete -F _dash_z_zone_running svcprop
complete -F _dash_z_zone_running wall
complete -F _dash_z_zone_configured auditreduce
complete -F _dash_z_zone_configured zoneadm
complete -F _dash_z_zone_configured zonecfg
# ex: filetype=sh
# vim: tabstop=2 shiftwidth=2 expandtab smartindent