fish-shell/share/completions/netctl-auto.fish

70 lines
3.6 KiB
Fish
Raw Normal View History

2016-12-02 22:39:56 +08:00
set -l cmds list start stop switch-to enable disable enable-all disable-all is-active is-enabled
2016-06-07 22:50:28 +08:00
# Helper function that prints network profiles managed by netctl-auto.
# If no argument is given, it prints all profiles.
# Othewise, it only prints the ones given as arguments witch are either:
# - active
# - disabled
# - other (meaning enabled but not active)
#
# For example, if you only want the enabled profiles, call it with
# the arguments active and other.
2016-06-07 22:50:28 +08:00
function __fish_print_netctl-auto_profile
set -l show_active false
set -l show_disabled false
set -l show_other false
for arg in $argv
switch $arg
case other
set show_other true
case disabled
set show_disabled true
case active
set show_active true
end
end
if not count $argv >/dev/null
set show_active true
set show_disabled true
set show_other true
end
2016-06-07 22:50:28 +08:00
for line in (netctl-auto list)
set -l profile (string sub -s 3 $line)
if string match -q '\**' -- $line
if test $show_active = true
printf "%s\t%s\n" $profile "Active profile"
end
else if string match -q "!*" -- $line
if test $show_disabled = true
printf "%s\t%s\n" $profile "Disabled profile"
end
2016-06-07 22:50:28 +08:00
else
if test $show_other = true
printf "%s\t%s\n" $profile "Profile"
end
2016-06-07 22:50:28 +08:00
end
end
end
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l help -d "Show help"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -l version -d "Show version"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a list -f -d "List all available profiles for automatic selection"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a start -f -d "Start automatic profile selection on interface"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a stop -f -d "Stop automatic profile selection on interface"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a switch-to -f -d "Switch to the given network profile"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a enable -f -d "Enable network profile for automatic selection"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a disable -f -d "Disable network profile for automatic selection"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a enable-all -f -d "Enable all profiles for automatic selection"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a disable-all -f -d "Disable all profiles for automatic selection"
2016-12-02 22:39:56 +08:00
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a is-active -f -d "Check whether specified profile is active"
complete -c netctl-auto -n "not __fish_seen_subcommand_from $cmds" -a is-enabled -f -d "Check whether specified profile is enabled"
2016-06-07 22:50:28 +08:00
complete -c netctl-auto -n "__fish_seen_subcommand_from switch-to" -f -a "(__fish_print_netctl-auto_profile other disabled)" -d "Profile"
complete -c netctl-auto -n "__fish_seen_subcommand_from enable" -f -a "(__fish_print_netctl-auto_profile disabled)" -d "Profile"
complete -c netctl-auto -n "__fish_seen_subcommand_from disable" -f -a "(__fish_print_netctl-auto_profile active other)" -d "Profile"
complete -c netctl-auto -n "__fish_seen_subcommand_from start stop" -f -a "(__fish_print_interfaces)"
2016-12-02 22:39:56 +08:00
complete -c netctl-auto -n "__fish_seen_subcommand_from is-enabled is-active" -x -a "(__fish_print_netctl-auto_profile active disabled other)"