apt install 包名 不能补全的问题解决

bash-completion安装正确后
形如apt ins** 可以自动补全为 apt install
但是形如 apt install aa*** 后面不能补全
解决:
bash-completion脚本会在/usr/share/bash-completion/completions/目录下预设一系列以常用命令为文件名的补全脚本,其中apt/apt-get中是对于apt/apt-get命令的补全脚本。
/usr/share/bash-completion/completions/apt中可以看到是利用
apt-cache --no-generate pkgnames "$cur"来实现补全,cur这里就是例子中输入的包名aa前缀。
直接在shell命令行执行apt-cache --no-generate pkgnames aa
报E: Could not open file - open (2: No such file or directory)错误。
看起来是apt-cache命令没有找到某个文件导致。
执行apt-config dump|grep Cache查看关于Cache的配置
Dir::Cache “var/cache/apt”;
Dir::Cache::archives “archives/”;
Dir::Cache::srcpkgcache “”;
Dir::Cache::pkgcache “”;

Binary::apt::APT::Cache “”;
Binary::apt::APT::Cache::Show “”;
Binary::apt::APT::Cache::Show::Version “2”;
Binary::apt::APT::Cache::AllVersions “0”;
Binary::apt::APT::Cache::ShowVirtuals “1”;
Binary::apt::APT::Cache::Search “”;
Binary::apt::APT::Cache::Search::Version “2”;
Binary::apt::APT::Cache::ShowDependencyType “1”;
Binary::apt::APT::Cache::ShowVersion “1”;
发现加粗两行配置为空,对比正常的ubuntu,该两行配如下:
Dir::Cache::srcpkgcache “srcpkgcache.bin”;
Dir::Cache::pkgcache “pkgcache.bin”;

搜索apt配置看看
grep “pkgcache” /etc/apt/apt.conf.d/ -Rn
结果:
/etc/apt/apt.conf.d/docker-clean:3: Dir::Cache::pkgcache “”; Dir::Cache::srcpkgcache “”;
把该记录注掉,重开终端。
apt install aa**
补全成功,一切正常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值