启用 Tab 补全
1、安装 bash-completion
软件包
bash
sudo apt install bash-completion
2、修改 /etc/bash.bashrc
文件(需要root权限,全局)或 ~/.bashrc
文件
v
# enable bash completion in interactive shells
# if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
# fi
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
v
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
# if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
# fi
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
3、最后 source 重载 /etc/bash.bashrc
文件或用户目录 .bashrc
文件
bash
source /etc/bash.bashrc
source .bashrc