From: "Florian Gamböck" <mail@floga.de>
To: git@vger.kernel.org
Cc: "Szeder Gábor" <szeder.dev@gmail.com>
Subject: [RFC PATCH 0/1] completion: Dynamic completion loading
Date: Sun, 8 Apr 2018 20:26:07 +0200 [thread overview]
Message-ID: <20180408182552.26289-1-mail@floga.de> (raw)
In this small patch I want to introduce a way to dynamically load completion
scripts for external subcommands.
A few years ago, you would put a completion script (which defines a Bash
function _git_foo for a custom git subcommand foo) into
/etc/bash_completion.d, or save it somewhere in your $HOME and source it
manually in your .bashrc.
Starting with bash-completion v2.0 (or, to be absolutely exact, the preview
versions started at v1.90), completion scripts are not sourced at bash startup
anymore. Rather, when typing in a command and trigger completion by pressing
the TAB key, the new bash-completion's main script looks for a script with the
same name as the typed command in the completion directory, sources it, and
provides the completions defined in this script.
However, that only works for top level commands. After a completion script has
been found, the logic is delegated to this script. This means, that the
completion of subcommands must be handled by the corresponding completion
script.
As it is now, git is perfectly able to call custom completion functions, iff
they are already defined when calling the git completion. With my patch, git
uses an already defined loader function of bash-completion (or continues
silently if this function is not found), loads an external completion script,
and provides its completions.
An example for an external completion script would be
/usr/share/bash-completion/completions/git-foo for a git subcommand foo.
Florian Gamböck (1):
completion: Load completion file for external subcommand
contrib/completion/git-completion.bash | 8 ++++++++
1 file changed, 8 insertions(+)
--
2.16.1
next reply other threads:[~2018-04-08 18:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-08 18:26 Florian Gamböck [this message]
2018-04-08 18:26 ` [RFC PATCH 1/1] completion: Load completion file for external subcommand Florian Gamböck
2018-04-08 18:29 ` Florian Gamböck
2018-04-09 18:26 ` Stefan Beller
2018-04-09 19:49 ` Florian Gamböck
2018-04-19 14:12 ` SZEDER Gábor
2018-04-08 18:26 ` [RFC PATCH 1/1] completion: load " Florian Gamböck
2018-04-08 22:59 ` Junio C Hamano
2018-04-09 7:29 ` Florian Gamböck
2018-04-09 9:36 ` Junio C Hamano
2018-04-09 13:36 ` Florian Gamböck
2018-04-09 22:06 ` Junio C Hamano
2018-04-10 9:37 ` Florian Gamböck
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=20180408182552.26289-1-mail@floga.de \
--to=mail@floga.de \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.