File: completion.sh

package info (click to toggle)
nix 2.34.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,744 kB
  • sloc: cpp: 111,546; sh: 10,664; perl: 689; yacc: 573; xml: 410; lex: 363; python: 285; ansic: 163; sql: 56; makefile: 35; exp: 22; sed: 6; ruby: 1
file content (30 lines) | stat: -rw-r--r-- 953 bytes parent folder | download | duplicates (2)
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
# shellcheck shell=bash
function _complete_nix {
    local -a words
    local cword cur
    _get_comp_words_by_ref -n ':=&' words cword cur
    local have_type
    while IFS= read -r line; do
        local completion=${line%%	*}
        if [[ -z $have_type ]]; then
            have_type=1
            if [[ $completion == filenames ]]; then
                compopt -o filenames
            elif [[ $completion == attrs ]]; then
                compopt -o nospace
            fi
            continue
        fi

        if [[ "${cur}" =~ "=" ]]; then
            # drop everything up to the first =. if a = is included, bash assumes this to be
            # an arg=value argument and the completion gets mangled (see #11208)
            completion="${completion#*=}"
        fi

        COMPREPLY+=("${completion}")
    done < <(NIX_GET_COMPLETIONS=$cword "${words[@]}" 2>/dev/null)
    __ltrim_colon_completions "$cur"
}

complete -F _complete_nix nix