From b032354a9f37d7f7c3b25aeca0fab1b8a36e17f6 Mon Sep 17 00:00:00 2001 From: NextAlone <12210746+NextAlone@users.noreply.github.com> Date: Wed, 27 Apr 2022 03:14:02 +0800 Subject: [PATCH] feat: completion for adb push and pull (#8901) --- share/completions/adb.fish | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/share/completions/adb.fish b/share/completions/adb.fish index 584dd819c..c6a35e351 100644 --- a/share/completions/adb.fish +++ b/share/completions/adb.fish @@ -75,6 +75,22 @@ function __fish_adb_list_files __fish_adb_run_command find -H "$token*" -maxdepth 0 -type f 2\>/dev/null end +function __fish_adb_completion_for_pull + set -l token (commandline -opc) + __fish_adb_list_files + if test (count $token) -gt 2 + __fish_complete_path + end +end + +function __fish_adb_completion_for_push + set -l token (commandline -opc) + __fish_complete_path + if test (count $token) -gt 2 + __fish_adb_list_files + end +end + # Generic options, must come before command complete -n __fish_adb_no_subcommand -c adb -s s -x -a "(__fish_adb_get_devices)" -d 'Device to communicate with' @@ -164,4 +180,5 @@ complete -n '__fish_seen_subcommand_from reconnect' -c adb -x -a device -d 'Kick # commands that accept listing device files complete -n '__fish_seen_subcommand_from shell' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device' -complete -n '__fish_seen_subcommand_from pull' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device' +complete -n '__fish_seen_subcommand_from pull' -c adb -f -a "(__fish_adb_completion_for_pull)" -d 'File on device' +complete -n '__fish_seen_subcommand_from push' -c adb -f -a "(__fish_adb_completion_for_push)" -d 'File on device'