File: completion.sh

package info (click to toggle)
nix 2.26.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,524 kB
  • sloc: cpp: 87,540; sh: 8,864; perl: 649; yacc: 466; xml: 410; javascript: 378; lex: 329; ansic: 215; python: 128; sql: 56; makefile: 33; exp: 5; ruby: 1
file content (29 lines) | stat: -rw-r--r-- 929 bytes parent folder | download
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
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