首页 > 系统相关 >ubuntu命令行自动补全

ubuntu命令行自动补全

时间:2023-01-28 01:33:05浏览次数:46  
标签:completion 补全 bashrc sudo etc 命令行 ubuntu bash

1、安装bash-completion

sudo apt-get install bash-completion

2、编辑~/.bashrc 文件

添加如下内容:

if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

3、使其立即生效

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

标签:completion,补全,bashrc,sudo,etc,命令行,ubuntu,bash
From: https://www.cnblogs.com/hhddd-1024/p/17069568.html

相关文章