This file is indexed.

/usr/share/bash-completion/completions/nut is in nut-client 2.7.2-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Bash completion function for Network UPS Tools 'upsc' command.
#
# Install in /etc/bash_completion.d (and run '. /etc/bash_completion if this
# has not been done in your startup files already).
#
# Charles Lepple <clepple@gmail>

_nut_local_upses()
{
    upsc -l 2>/dev/null
}

_nut_upses()
{
    upsc -l 2>/dev/null
    # Example syntax:
    echo UPS@host:port
    # ... could add others from upsmon.conf, etc.
}

###

_nut_upsc_completion()
{
    local upses cur

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}

    # The 'list' options can take a hostname and a port, but we don't complete
    # the port number:
    case "$prev" in
        -l|-L)
            COMPREPLY=( $(compgen -A hostname ${cur}) ) ; return 0 ;;
    esac

    # If the user starts to type an option, then only offer options for that word:
    if [[ "$cur" == -* ]]; then
            COMPREPLY=( $(compgen -W "-l -L" -- ${cur}) ) ; return 0
    fi

    upses="$(_nut_upses)"
    COMPREPLY=( $(compgen -W "-l -L $upses" -- ${cur}) )
    return 0
}

complete -F _nut_upsc_completion upsc

###

_nut_upscmd_completion()
{
    local cur options prev pprev upses

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    (( COMP_CWORD >= 3 )) && pprev=${COMP_WORDS[COMP_CWORD-3]}
    options="-h -l -u -p"

    case "$prev" in
        -u|-p) # TODO: match against upsd.users, if readable.
            COMPREPLY=( ) ; return 0 ;;
	-l) 
            upses="$(_nut_upses)"
            COMPREPLY=( $(compgen -W "$upses" -- ${cur}) ) ; return 0 ;;
	upscmd)
	    upses="$(_nut_upses)"
	    COMPREPLY=( $(compgen -W "$options $upses" -- ${cur}) ) ; return 0 ;;
    esac

    # If the user starts to type an option, then only offer options for that word:
    if [[ "$cur" == -* ]]; then
            COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) ; return 0
    fi

    # If we have hit the end of the command line, then don't try and match the command as a host:
    [[ "$pprev" == -* || "$pprev" == "upscmd" ]] && return 0

    # Get the list of commands from the UPS named in the previous word:
    local cmds
    cmds=$(upscmd -l $prev 2>/dev/null | tail -n +3 | sed 's/ - .*//' )
    COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )

    return 0
}

complete -F _nut_upscmd_completion upscmd

###

_nut_upsd_completion()
{
    local cur options prev

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    options="-c -D -f -h -r -u -V -4 -6"

    case "$prev" in
	-c) # commands:
            COMPREPLY=( $(compgen -W "reload stop" -- ${cur}) ) ; return 0 ;;
	-r) # chroot:
            COMPREPLY=( $(compgen -A directory -- ${cur}) ) ; return 0 ;;
        -u) # system user, not in upsd.users
            COMPREPLY=( $(compgen -u -- ${cur}) ) ; return 0 ;;
    esac

    # Only options, no other words:
    COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) ; return 0

    return 0
}

complete -F _nut_upsd_completion upsd

###

_nut_upsdrvctl_completion()
{
    local cur options prev upses

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    options="-h -r -t -u -D"

    case "$prev" in
	-r) # chroot:
            COMPREPLY=( $(compgen -A directory -- ${cur}) ) ; return 0 ;;
        -u) # system user, not in upsd.users
            COMPREPLY=( $(compgen -u -- ${cur}) ) ; return 0 ;;
	start|stop|shutdown)
    	     upses="$(_nut_local_upses)"
	     COMPREPLY=( $(compgen -W "$upses" -- ${cur}) ) ; return 0 ;;
    esac

    # If the user starts to type an option, then only offer options for that word:
    if [[ "$cur" == -* ]]; then
            COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) ; return 0
    fi

    # Don't auto-complete shutdown because it doesn't usually do what you want (upsmon -c fsd):
    COMPREPLY=( $(compgen -W "$options start stop" -- ${cur}) )

    return 0
}

complete -F _nut_upsdrvctl_completion upsdrvctl

###

_nut_upsmon_completion()
{
    local cur options prev

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    options="-c -D -h -K -u -4 -6"

    case "$prev" in
	-c) # commands:
            COMPREPLY=( $(compgen -W "fsd reload stop" -- ${cur}) ) ; return 0 ;;
        -u) # system user, not in upsd.users
            COMPREPLY=( $(compgen -u -- ${cur}) ) ; return 0 ;;
    esac

    # Only options, no other words:
    COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) ; return 0

    return 0
}

complete -F _nut_upsmon_completion upsmon

###

_nut_upsrw_completion()
{
    local cur options prev upses

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    options="-s -u -p -h"

    upses="$(_nut_upses)"

    case "$prev" in
        -u|-p) # TODO: match against upsd.users, if readable.
            COMPREPLY=( ) ; return 0 ;;
	-l)
            COMPREPLY=( $(compgen -W "$upses" -- ${cur}) ) ; return 0 ;;
    esac

    # If the user starts to type an option, then only offer options for that word:
    if [[ "$cur" == -* ]]; then
            COMPREPLY=( $(compgen -W "$options" -- ${cur}) ) ; return 0
    fi

    COMPREPLY=( $(compgen -W "$options $upses" -- ${cur}) )
    return 0
}

complete -F _nut_upsrw_completion upsrw