fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

ccoVeilleFix typos in completions scripts0df6fa791

master
3.6 KiB69 linesraw
1set -l cmds list start stop switch-to enable disable enable-all disable-all is-active is-enabled
2
3# Helper function that prints network profiles managed by netctl-auto.
4# If no argument is given, it prints all profiles.
5# Otherwise, it only prints the ones given as arguments witch are either:
6#    - active
7#    - disabled
8#    - other (meaning enabled but not active)
9#
10# For example, if you only want the enabled profiles, call it with
11# the arguments active and other.
12function __fish_print_netctl-auto_profile
13    set -l show_active false
14    set -l show_disabled false
15    set -l show_other false
16
17    for arg in $argv
18        switch $arg
19            case other
20                set show_other true
21            case disabled
22                set show_disabled true
23            case active
24                set show_active true
25        end
26    end
27
28    if not count $argv >/dev/null
29        set show_active true
30        set show_disabled true
31        set show_other true
32    end
33
34    for line in (netctl-auto list)
35        set -l profile (string sub -s 3 $line)
36        if string match -q '\**' -- $line
37            if test $show_active = true
38                printf "%s\t%s\n" $profile "Active profile"
39            end
40        else if string match -q "!*" -- $line
41            if test $show_disabled = true
42                printf "%s\t%s\n" $profile "Disabled profile"
43            end
44        else
45            if test $show_other = true
46                printf "%s\t%s\n" $profile Profile
47            end
48        end
49    end
50end
51
52complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l help -d "Show help"
53complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l version -d "Show version"
54complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a list -f -d "List all available profiles for automatic selection"
55complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a start -f -d "Start automatic profile selection on interface"
56complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a stop -f -d "Stop automatic profile selection on interface"
57complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a switch-to -f -d "Switch to the given network profile"
58complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a enable -f -d "Enable network profile for automatic selection"
59complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a disable -f -d "Disable network profile for automatic selection"
60complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a enable-all -f -d "Enable all profiles for automatic selection"
61complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a disable-all -f -d "Disable all profiles for automatic selection"
62complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a is-active -f -d "Check whether specified profile is active"
63complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a is-enabled -f -d "Check whether specified profile is enabled"
64
65complete -c netctl-auto -n "__fish_seen_subcommand_from switch-to" -f -a "(__fish_print_netctl-auto_profile other disabled)" -d Profile
66complete -c netctl-auto -n "__fish_seen_subcommand_from enable" -f -a "(__fish_print_netctl-auto_profile disabled)" -d Profile
67complete -c netctl-auto -n "__fish_seen_subcommand_from disable" -f -a "(__fish_print_netctl-auto_profile active other)" -d Profile
68complete -c netctl-auto -n "__fish_seen_subcommand_from start stop" -f -a "(__fish_print_interfaces)"
69complete -c netctl-auto -n "__fish_seen_subcommand_from is-enabled is-active" -x -a "(__fish_print_netctl-auto_profile active disabled other)"