Bash completion

From OpenZFS on OS X
Jump to: navigation, search

Assuming you already have Homebrew installed

Bash version < 4

brew install bash-completion

Add the following lines to your ~/.bash_profile:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
        . $(brew --prefix)/etc/bash_completion
fi

Install the ZFS bash completions:

cd /usr/local/etc/bash_completion.d
curl -O https://raw.githubusercontent.com/openzfs/zfs/master/contrib/bash_completion.d/zfs
chmod +x /usr/local/etc/bash_completion.d/zfs

Source the added file (source /usr/local/etc/bash_completion.d/zfs) or open a new terminal window.

Bash version ≥ 4

brew install bash-completion@2

Add the following lines to your ~/.bash_profile or ~/.bashrc (depending on your preferred setup of startup files):

export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
if [ -r "/usr/local/etc/profile.d/bash_completion.sh" ]; then 
        . "/usr/local/etc/profile.d/bash_completion.sh"
fi

Install the ZFS bash completions:

cd /usr/local/share/bash-completion/completions
curl -O https://raw.githubusercontent.com/openzfs/zfs/master/contrib/bash_completion.d/zfs
chmod +x /usr/local/share/bash-completion/completions/zfs

Source the added file (source /usr/local/share/bash-completion/completions/zfs) or open a new terminal window.