aboutsummaryrefslogtreecommitdiffgithub
path: root/bash_completion/nsdo
blob: c3e32f19c8d5cd440046e29b74bb1fa47fca5d71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# nsdo(1) completion                                     -*- shell-script -*-

_nsdo()
{
    local cur prev words cword
    _init_completion || return

    if [[ $COMP_CWORD -eq 1 ]]; then
        compopt -o filenames

        # assume that the filenames in /var/run/netns don't contain
        # newlines(!)
        local IFS=$'\n'
        COMPREPLY=( $(compgen -W "$(ip netns list)" -- "$cur") )
    else
        _command_offset 2
    fi
} && complete -F _nsdo nsdo

# ex: ts=4 sw=4 et filetype=sh