Commit 3b5d7939d9a660a83e29a86e6bab234f3e9f2dcb added completion for
`brew link` options, but disabled completion of the actual command
itself.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Rationale: some users insist on replacing the /usr/bin/ruby symlink
to point to another ruby on their system, which may break homebrew.
Use the full Framework path instead, which is less likely to be tampered with.
This also reorganizes the brew --config checks to reflect the different path.
FixesHomebrew/homebrew#12009.
ClosesHomebrew/homebrew#12333.
Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
This was probably silly and I'm probably the only person that ever used
it. I still do, actually, but it's not really a completion function,
it's simple enough to just stick in a shell startup script, and removing
it makes the completion script usable under the new dynamic loading
scheme provided by bash-completion 1.99+.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Using an inline Ruby script we can hit the GitHub API and look for
repositories that match the tap naming scheme. The results are cached
for the duration of the current shell session, so going over the network
is a once-per-shell-session cost.
There are a few false positives, but not much we can do about that at
this point, as taps do not have to be in the fork network of any
specific repository.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
So you can do e.g.
$ brew install adamv<TAB>
Display all 106 possibilities? (y or n)
$ brew install adamv/alt/openss<TAB>
adamv/alt/openssh adamv/alt/openssl098 adamv/alt/openssl100
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
The script was lacking structure and had grown a number of one-off hacks
that would be better as reusable functions. So,
- give each subcommand that has completions it's own function
- move completion of formulae, installed brews, and outdated brews into
reusable functions
- introduce a general __brewcomp() function that takes a string of tab,
space, and/or newline separated items and converts all seperators to
newlines, and then generates a reply with compgen().
These changes should allow for easier addition of new features in the
future.
As a bonus, completion for `brew log` will include git-log options if
the git completion script is also loaded.
_brew_to_completion() is kept around for compatiblity.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This will be useful for shell tab completion when something like `brew
install <formula> --version <version>` is implemented.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
We make the assumption that the first non-option word is the command
being invoked.
Originally I was trying to allow command completion for non-standard
command lines like
$ brew --verbose inst<TAB>
but right now executing something like that doesn't actually work. Which
is interesting, because the man page implies that it should. Either the
man page is incorrect, or something was broken between then and now.
Anyway, it would probably be safe to just assume that COMP_WORDS[1] is
the command, and we do make that assumption in other places. But if we
ever do allow things like "brew --option command", this will be useful.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
It is often useful to be reminded that you are, in fact, in the middle
of a debug or interactive install. We provided this reminder in the form
of HOMEBREW_DEBUG_INSTALL, but we can make this even easier for the end
user to consume by exposing it in the form of a shell function.
When HOMEBREW_DEBUG_INSTALL is set, the __brew_ps1() function returns
the string "(formula_name|DEBUG)" by default (much like the __git_ps1()
output when performing some long-running operation, e.g.
"(branch|REBASE-i)". The formatting around "formula_name|DEBUG" can be
customized by passing a format string to the function.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
We already have option completion for `brew install`; now we have it for
all core commands, and the --cache, --cellar, and --prefix flags now
have appropriate formula completion.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Selection of generic installation options, such as `--HEAD`, is now lumped
together with selection of formulae-specific options.
This allows any installation option to be tab-completed *before or after* the
formula name is specified.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
If a formula is given, it will be checked for missing deps.
The formula does not have to be installed first.
Without a formula list, still checks all installed brews.
i.e. `--force --debug --use-llvm --ignore-dependencies --HEAD`
Additionally:
* Use a cleaner `if` block in install options completion case.
* De-dupe options for subsequent completion (e.g. stop offering --foo once
--foo option has been used).
Signed-off-by: Adam Vandenberg <flangy@gmail.com>