From: eli-schwartz <eli-schwartz@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: git-extras: install completions
Date: Wed, 01 Sep 2021 03:06:25 +0200 [thread overview]
Message-ID: <20210901010625.Yu5HHvUhIgaG5zxQ-TrXxye_Qnw_hwbSIAk4Hbc381s@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-32767@inbox.vuxu.org>
[-- Attachment #1: Type: text/plain, Size: 2818 bytes --]
New comment by eli-schwartz on void-packages repository
https://github.com/void-linux/void-packages/pull/32767#issuecomment-909769962
Comment:
Shell completion systems follow a basic well known pattern, and what we are looking at here is, specifically, how that gets loaded at runtime.
There are two basic methods for loading a shell completion:
- source it in shell init
- source completion file in bashrc/config.fish/zshrc
- (bash-only) add file to `/etc/bash_completion.d/`, the "legacy directory", which, if completions are enabled, is looped over and every file in there gets sourced
- use a completion auto-loader
- bash: completionsdir, tab complete for commands without a defined completion will run `_completion_loader` which in turn runs `__load_completion` and returns successful injection, or falls back to a minimal (defined stub) completion for commands that have no completion file. Upon successfully returning injected completion, it messages bash via `return 124` to retry completion, using the loaded completion
- zsh: all fpath contents are scanned and indexed for files containing the comment `#compdef` on the first line, the rest of that line contains a description of the completions the file offers. ONLY IF A COMPDEF EXISTS, that file will then be consulted when you perform a tab completion for that command. The rest of the file then gets sourced dynamically when needed, and is expected to follow very specific styles (utilizing completion widgets e.g. `_arguments`); a valid compdef file is IIRC incompatible with a valid "just source this in shell init".
- fish: my understanding is it works like bash
Now, the problem with git-extras should be obvious. None of the files correspond to what you're actually completing. You tab complete `git release <TAB>` or something like that, not `git-extras` and not even `git extras`. So, bash and fish will never try to load the completion file, though they will try to load `git.fish` or `/usr/share/bash-completion/completions/git`. And the zsh completion uses zstyle, not `#compdef`.
So, this is why none of them, at all, work without manually sourcing the file. The auto-load directories which vcompletion sets up, are useless and do nothing.
...
Coincidentally, bash's legacy /etc/bash_completion.d/ directory does work, because the legacy bash completion style was "have some directory and source every file there on startup". Some completions, like git-extras, aren't even compatible with the non-legacy style, so they intentionally install to the legacy dir. The git-extras Makefile does precisely this.
`vcompletion etc/bash_completion.sh bash` would install to the `_completion_loader` compatible directory and do nothing.
zsh and fish do not have an analogue to bash-completion's legacy dir
prev parent reply other threads:[~2021-09-01 1:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-30 22:09 [PR PATCH] " kkga
2021-08-30 22:21 ` [PR PATCH] [Updated] " kkga
2021-08-30 22:47 ` [PR PATCH] [Merged]: " ericonr
2021-08-30 23:07 ` ericonr
2021-08-31 5:41 ` kkga
2021-08-31 5:44 ` kkga
2021-08-31 19:38 ` ericonr
2021-09-01 0:53 ` eli-schwartz
2021-09-01 0:58 ` eli-schwartz
2021-09-01 1:01 ` eli-schwartz
2021-09-01 1:02 ` eli-schwartz
2021-09-01 1:06 ` eli-schwartz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210901010625.Yu5HHvUhIgaG5zxQ-TrXxye_Qnw_hwbSIAk4Hbc381s@z \
--to=eli-schwartz@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).