Add support for git-* command auto-completion#7075
Conversation
|
This is a really nice approach! We can extend it to similar commands in future. |
|
One problem with this approach: It reads the I'm not sure how to solve it. In a pinch skipping that directory (including checking $XDG_DATA_HOME) would probably do. |
|
Hmm indeed, those ones that are generated from man page. So I just checked and in fact, since those not command -q $cmd
and continueguard. (e.g. even though there are bunch of things like Having said that, I'm not sure how useful those auto-generated completions are for custom git-* command (um probably?). If we want to save reductant check of |
Indeed. I'd still rather go through the directory list to remove it. E.g. # Get the path to the generated completions
# If $XDG_DATA_HOME is set, that's it, if not, it will be removed and ~/.local/share will remain.
set -l generated_path $XDG_DATA_HOME/fish/generated_completions ~/.local/share/fish/generated_completions
# We don't want to modify $fish_complete_path here, so we make a copy.
set -l complete_dirs $fish_complete_path
# Remove the path to the generated completions if it is in the list
set -l ind (contains -i -- $generated_path[1] $complete_dirs); and set -e complete_dirs[$ind]
for git_ext in $list/git-*.fish
# ... |
|
Thanks @faho for your kind suggestions |
|
Merged. Thank you and sorry for the delay! |
Fixes issue #7071
Description
This PR addresses #7071 by loading
git-*.fishcompletion in the maingit.fish.This approach addresses the following
gitif the user had not installed anygit-*.fishcompletion file, other than the searches for completion file during initialisation.git-*.fishcompletion file, this approach won't loads them if the user had not installed the executable. Therefore, it won't clutter the shell by loading unnecessary completion.git-*.fishit founds.git <foo>. This approach allows you to addgit-foo.fishto your completion file and it will load it whens git is invoked.git.fishit already tries to provide completion for customgit-*executable, so it makes sense to also load their completion, if exists, afterwards.TODOs: