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.
-
Install bash-completion, if it isn’t already:
# Debian/Ubuntusudo apt install bash-completion# Fedorasudo dnf install bash-completion# Arch Linuxsudo pacman -S bash-completion# macOS — note the @2; the v1 formula is for Bash 3.2brew install bash-completion@2 -
Check whether it’s loaded. Run
complete -pin 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. -
Start a new brush to pick up the change.
Check that it worked
Section titled “Check that it worked”<TAB> below means pressing the Tab key:
ssh <TAB> # hosts from your ~/.ssh/configman <TAB> # manual pagesssh -<TAB> # ssh's optionsWhen completion doesn’t work
Section titled “When completion doesn’t work”- Nothing completes at all — bash-completion probably isn’t sourced. Check
complete -pin 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.
Open source under the MIT license. Built in the open by the brush community.