summaryrefslogtreecommitdiff
path: root/usr/src/cmd/nsadmin/bash/bash_completion.d/machines
blob: 05de1b75a4283e713016de5ba1f43d2fca6bc13c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
_machine()
{
    local cur prev opts base
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    if [[ ${prev} == 'machine-json' ]]; then
        machines=$(zoneadm list -cp | grep -v ':global:' | cut -d':' -f2,5 | tr ':' '\n' | sort | uniq)
        COMPREPLY=( $(compgen -W "${machines}" -- ${cur}) )
    else
        # Just expand files by default
        COMPREPLY=( $(compgen -f -- ${cur}) )
    fi

    return 0
}

complete -F _machine machine-json