mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
completions/git: use builtin path for finding subcommands
This is more elegant and efficient. No functional change.
As suggested by 2da1a4ae7
(completions/git: Fix git-foo commands, 2023-01-09).
This commit is contained in:
parent
f033b4df7d
commit
befa240756
1 changed files with 6 additions and 9 deletions
|
@ -2386,16 +2386,13 @@ end
|
|||
|
||||
# source git-* commands' autocompletion file if exists
|
||||
set -l __fish_git_custom_commands_completion
|
||||
for file in $PATH/git-*
|
||||
not command -q $file
|
||||
and continue
|
||||
|
||||
set -l subcommand (string replace -r -- '.*/git-([^/]*)$' '$1' $file)
|
||||
|
||||
for file in (path filter -xZ $PATH/git-* | path basename)
|
||||
# Already seen this command earlier in $PATH.
|
||||
contains -- $subcommand $__fish_git_custom_commands_completion
|
||||
contains -- $file $__fish_git_custom_commands_completion
|
||||
and continue
|
||||
|
||||
complete -c git -f -n "__fish_git_using_command $subcommand" -a "(__fish_git_complete_custom_command $subcommand)"
|
||||
set -a __fish_git_custom_commands_completion $subcommand
|
||||
# Running `git foo` ends up running `git-foo`, so we need to ignore the `git-` here.
|
||||
set -l cmd (string replace -r '^git-' '' -- $file)
|
||||
complete -c git -f -n "__fish_git_using_command $cmd" -a "(__fish_git_complete_custom_command $cmd)"
|
||||
set -a __fish_git_custom_commands_completion $file
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue