File: flatpak.fish

package info (click to toggle)
flatpak 1.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,020 kB
  • sloc: ansic: 101,028; xml: 11,453; sh: 4,871; python: 2,251; yacc: 1,236; makefile: 86; csh: 20
file content (45 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (6)
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
function __fish_complete_flatpak
    set current_cmd (commandline -p)
    set current_position (commandline -C)
    set current_token (commandline -ct)
    command flatpak complete "$current_cmd" "$current_position" "$current_token" | while read fp_sugg
        set sugg (string trim -- "$fp_sugg")
        switch "$sugg"
            case __FLATPAK_FILE
                __fish_complete_path "$current_token"
            case __FLATPAK_BUNDLE_FILE
                __fish_complete_suffix "$current_token" '.flatpak'
            case __FLATPAK_BUNDLE_OR_REF_FILE
                __fish_complete_suffix "$current_token" '.flatpak'
                __fish_complete_suffix "$current_token" '.flatpakref'
            case __FLATPAK_DIR
                __fish_complete_directories "$current_token"
            case '*'
                # completing a value for option
                if string match -- "--*=" "$current_token"
                    echo "$current_token$sugg"
                else
                    echo "$sugg"
                end
        end
    end
    return
end

function __fish_flatpak_complete_files
    if __fish_seen_subcommand_from run build
        set pos_args 0
        for t in (commandline -co)
            if string match --invert -- "-*" "$t"
                set pos_args (math "$pos_args+1")
            end
        end
        if test $pos_args -gt 2
            return 0
        end
    end
    return 1
end

complete -c flatpak -f -n "not __fish_flatpak_complete_files" -a '(__fish_complete_flatpak)'
complete -c flatpak -n "__fish_flatpak_complete_files" -a '(__fish_complete_flatpak)'