From 1dcf8c689cb3e35d2b727903068c2df27c357ca6 Mon Sep 17 00:00:00 2001 From: Richard Schneeman Date: Thu, 6 Dec 2018 12:04:08 -0600 Subject: [PATCH] Update bash completion docs When I try to run the proposed script in my `~/.bashrc` file I get this output: ``` -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: have: command not found -bash: [: =: unary operator expected # ... ``` It goes on for quite some time and does not give me bash completion. When I execute `source "$(brew --prefix)/etc/bash_completion"` it works and I get bash completion. This script also emits a helpful error message letting people know if bash completion was not installed already. I'll also add that the bash completion script takes a fairly long amount of time. I've seen between one quarter and a half of a second to execute it: ``` $ time source "$(brew --prefix)/etc/bash_completion" real 0m0.254s ``` Though that's unrelated to this PR, making a note of it. --- docs/Shell-Completion.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Shell-Completion.md b/docs/Shell-Completion.md index c256368a0b..9e1fbdc1e6 100644 --- a/docs/Shell-Completion.md +++ b/docs/Shell-Completion.md @@ -7,13 +7,14 @@ Homebrew comes with completion definitions for the `brew` command. Some packages You must configure your shell to enable the completion support. This is because the Homebrew-managed completions are stored under `HOMEBREW_PREFIX`, which your system shell may not be aware of, and because it is difficult to automatically configure `bash` and `zsh` completions in a robust manner, so the Homebrew installer cannot do it for you. ## Configuring Completions in `bash` + To make Homebrew's completions available in `bash`, you must source the definitions as part of your shell startup. Add the following to your `~/.bashrc` file: ```sh if type brew 2&>/dev/null; then - for completion_file in $(brew --prefix)/etc/bash_completion.d/*; do - source "$completion_file" - done + source "$(brew --prefix)/etc/bash_completion" +else + echo "run: brew install git bash-completion" fi ```