From d4462912e69ed2eb970ea715c7430d0a2c134619 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 24 Mar 2020 20:10:08 +0100 Subject: [PATCH] Restore directory completions for subcommands Fixes #6798 This re-adds some false positives: functions, builtins and abbreviations are suggested after commands like sudo but I don't think anyone had complained about that. (cherry picked from commit 2a89873e6d686fcff1d26d0914a8b9f90b7cc308) --- CHANGELOG.md | 1 + share/functions/__fish_complete_external_command.fish | 2 +- share/functions/__fish_complete_subcommand.fish | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcffa33f2..39630695b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This is a bug fix release containing important fixes since 3.1.0. It - fixes 256 colors when $TERM starts with xterm, does not include "256color" and $TERM_PROGRAM is not set, as a workaround for old Terminal.app that was misapplied (#6701). - fixes error spew in the hg prompt when the working directory doesn't exist anymore (#6699) - fixes hosts with multiple aliases in the ssh config (#6698). +- fixes subcommand tab completion for commands like "watch" where executables that are not in $PATH were not suggested (#6798). - improves compatibility with macOS code signing - improves the `flatpak` (#6581) and `kill` (#6636) completions - plus some typo and link fixes and minor adjustments to the documentation (#6627, #6642, #6646, #6647, #6657) diff --git a/share/functions/__fish_complete_external_command.fish b/share/functions/__fish_complete_external_command.fish index 2790c61e7..6d9a25609 100644 --- a/share/functions/__fish_complete_external_command.fish +++ b/share/functions/__fish_complete_external_command.fish @@ -1,3 +1,3 @@ function __fish_complete_external_command - command find $PATH/ -maxdepth 1 -perm -u+x 2>&- | string match -r '[^/]*$' + complete -C "$argv[1]" end diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index bd7cc5009..b622474fa 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -49,7 +49,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin end if test $allow_functions_and_builtins = false && test (count $subcommand) -eq 1 - __fish_complete_external_command + __fish_complete_external_command "$subcommand" else printf "%s\n" (complete -C "$subcommand") end