Linux系统安装Bash自动补全(bash-completion)

一、安装工具

1、Linux 发行版

Debian/Ubuntu
复制代码
sudo apt-get update && sudo apt-get install -y bash-completion
RHEL/CentOS 7+
复制代码
sudo yum install -y bash-completion  # CentOS 7  
sudo dnf install -y bash-completion  # CentOS 8+/Fedora  

2、源码安装(通用)

复制代码
git clone https://github.com/scop/bash-completion.git  
cd bash-completion  
autoreconf -i  
./configure  
make && sudo make install  

安装后需在 ~/.bashrc 添加加载脚本

二、配置加载

安装完成后,需在 ~/.bashrc~/.bash_profile 中添加以下内容

复制代码
if [ -f /usr/share/bash-completion/bash_completion ]; then  
  . /usr/share/bash-completion/bash_completion  
fi  

生效配置

复制代码
source ~/.bashrc  # 或重启终端  

然后校验下自动补全功能就完成了

相关推荐
程序员编程指南21 分钟前
Qt开发环境搭建全攻略(Windows+Linux+macOS)
linux·c语言·c++·windows·qt
我爱学嵌入式44 分钟前
C语言第 4 天学习笔记:位运算、流程控制与输入输出
linux·c语言·笔记
寒水馨1 小时前
聊聊DevOps,开发与运维如何分工协作?
运维·ci/cd·开发·devops
西红柿煎蛋1 小时前
WSL2子系统连接USB
linux
豆是浪个1 小时前
Linux(Centos 7.6)命令详解:jobs
linux·运维·centos
Fireworkitte2 小时前
ps aux 和 ps -ef
linux·运维·vim
hweiyu002 小时前
DevOps是什么?
运维·devops
想睡hhh3 小时前
Linux文件——文件系统Ext2(1)_理解硬件
linux·服务器·磁盘
c_zyer3 小时前
从零构建实时通信引擎:Freeswitch源码编译与深度优化指南
运维·freeswitch·sip