diff --git a/share/completions/apt.fish b/share/completions/apt.fish index e7b2d8523..2173f46d7 100644 --- a/share/completions/apt.fish +++ b/share/completions/apt.fish @@ -1,5 +1,7 @@ # Completions for the `apt` command +set -l pkg_subcmds install remove upgrade full-upgrade show search purge changelog policy depends rdepends + function __fish_apt_no_subcommand -d 'Test if apt has yet to be given the subcommand' for i in (commandline -opc) if contains -- $i update upgrade full-upgrade search list install show remove edit-sources purge changelog autoremove depends rdepends @@ -9,15 +11,6 @@ function __fish_apt_no_subcommand -d 'Test if apt has yet to be given the subcom return 0 end -function __fish_apt_use_package -d 'Test if apt command should have packages as potential completion' - for i in (commandline -opc) - if contains -- $i install remove upgrade full-upgrade show search purge changelog policy depends rdepends - return 0 - end - end - return 1 -end - function __fish_apt_subcommand set subcommand $argv[1] set -e argv[1] @@ -36,10 +29,10 @@ end function __fish_apt_option set subcommand $argv[1] set -e argv[1] - complete -f -c apt -n "__fish_apt_using_subcommand $subcommand" $argv + complete -f -c apt -n "__fish_seen_subcommand_from $subcommand" $argv end -complete -c apt -n '__fish_apt_use_package' -a '(__fish_print_packages)' -d 'Package' +complete -c apt -n '__fish_seen_subcommand_from $pkg_subcmds' -a '(__fish_print_packages)' -d 'Package' # Support flags complete -x -f -c apt -s h -l help -d 'Display help' diff --git a/share/completions/sudo.fish b/share/completions/sudo.fish index af6156220..705f17946 100644 --- a/share/completions/sudo.fish +++ b/share/completions/sudo.fish @@ -23,8 +23,6 @@ complete -c sudo -s s -d "Run the given command in a shell" complete -c sudo -s u -a "(__fish_complete_users)" -x -d "Run command as user" complete -c sudo -s v -n "__fish_no_arguments" -d "Validate the credentials, extending timeout" -complete -c sudo -d "Command to run" -x -a "(__fish_complete_subcommand_root -u -g)" - # Or provide completions function __fish_complete_sudo_payload set -l tokens (commandline -co) diff --git a/share/functions/__fish_complete_subcommand_root.fish b/share/functions/__fish_complete_subcommand_root.fish deleted file mode 100644 index d434d0cbb..000000000 --- a/share/functions/__fish_complete_subcommand_root.fish +++ /dev/null @@ -1,4 +0,0 @@ -function __fish_complete_subcommand_root -d "Run the __fish_complete_subcommand function using a PATH containing /sbin and /usr/sbin" - set -lx -p PATH /sbin /usr/sbin 2>/dev/null - __fish_complete_subcommand $argv -end