ubuntu命令行自动补全
1、安装 bash-completion
sudo apt-get install bash-completion
2、编辑~/.bashrc 文件
vim ~/.bashrc
# 添加如下内容
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# 立即生效
source ~/.bashrc
注:在使用ubuntu的时候有时候会出现sudo 输入命令的时候不能自动补全,这着实让人郁闷:
在.bashrc这个文件中以下内容取消注释
# enable programmable completion features (you don’t need to enable
# this, if it’s already enabled in /etc/bash.bashrc and /etc/profiles
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
手动加入sudo和man的tab自动补全功能,需在~/.bashrc中加入:
#Enabling tab-completion
complete -cf sudo
complete -cf man