summaryrefslogtreecommitdiffstats
path: root/contrib/bash-completion
blob: 49f1e6b99b9ccdfc39230b3c0b2f4f15db7930be (plain)
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
# netctl completion

_netctl()
{
    local cur prev prof

    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    prof=$(find -L /etc/network.d -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n")

    case $COMP_CWORD in
      1)
        COMPREPLY=( $(compgen -W "--help --version list store restore stop-all start stop restart switch-to status enable disable reenable" -- $cur) )
      ;;
      2)
        case $prev in
          start|stop|restart|switch-to|status|enable|disable|reenable)
            mapfile -t COMPREPLY < <(IFS=$'\n'; compgen -W "$prof" -- $cur)
          ;;
        esac
      ;;
      *)
        COMPREPLY=()
      ;;
    esac
} &&
complete -F _netctl netctl


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