Clean up completions a little bit

This commit is contained in:
Mahmoud Al-Qudsi 2018-05-20 14:07:56 -05:00
parent fd4b3f2c26
commit 0a337a9d8e
3 changed files with 4 additions and 17 deletions

View File

@ -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'

View File

@ -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)

View File

@ -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