Skip to content

Set up bash-completion

brush supports programmable completion out of the box — complete, compgen and compopt — so completion scripts written for Bash work in brush. This guide sets up the bash-completion package, which adds completions for a large set of common commands.

  1. Install bash-completion, if it isn’t already:

    # Debian/Ubuntu
    sudo apt install bash-completion
    # Fedora
    sudo dnf install bash-completion
    # Arch Linux
    sudo pacman -S bash-completion
    # macOS — note the @2; the v1 formula is for Bash 3.2
    brew install bash-completion@2
  2. Check whether it’s loaded. Run complete -p in brush. If it prints nothing, or only a few entries from tools you set up yourself, source bash-completion from your ~/.bashrc (some distributions load it only from a profile script, which a non-login shell never reads):

    ~/.bashrc (Linux)
    [[ -r /usr/share/bash-completion/bash_completion ]] && \
    . /usr/share/bash-completion/bash_completion
    ~/.bashrc (macOS, Homebrew)
    [[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && \
    . "$(brew --prefix)/etc/profile.d/bash_completion.sh"

    A login shell doesn’t read ~/.bashrc; see which files are read.

  3. Start a new brush to pick up the change.

<TAB> below means pressing the Tab key:

ssh <TAB> # hosts from your ~/.ssh/config
man <TAB> # manual pages
ssh -<TAB> # ssh's options
  • Nothing completes at all — bash-completion probably isn’t sourced. Check complete -p in a fresh shell; empty output means step 2 didn’t take effect.
  • It works in Bash but not brush — that’s a compatibility bug worth filing, with the command and the completion script involved.

Last updated:

Open source under the MIT license. Built in the open by the brush community.