Đây là một thiếu sót trong bash-completegói, không apt. Có vẻ như sự hoàn thành chưa tồn tại, vì vậy tôi đã loại bỏ những gì tôi có thể cho aptlệnh (đó không phải là lệnh được ghi chép tốt nhất từng tồn tại!)
Sau đây là một điều chỉnh từ sự apt-gethoàn thành hiện có (với các phần tử được loại bỏ và các bit được thêm vào từ apt-cachesự hoàn thành của nó). Chạy sudoedit /usr/share/bash-completion/completions/aptvà dán như sau:
# Debian apt(8) completion -*- shell-script -*-
_apt()
{
local cur prev words cword
_init_completion || return
local special i
for (( i=0; i < ${#words[@]}-1; i++ )); do
if [[ ${words[i]} == @(list|search|show|update|install|remove|upgrade|full-upgrade|edit-sources|dist-upgrade|purge) ]]; then
special=${words[i]}
fi
done
if [[ -n $special ]]; then
case $special in
remove|purge)
if [[ -f /etc/debian_version ]]; then
# Debian system
COMPREPLY=( $( \
_xfunc dpkg _comp_dpkg_installed_packages $cur ) )
else
# assume RPM based
_xfunc rpm _rpm_installed_packages
fi
return 0
;;
*)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
2> /dev/null ) )
return 0
;;
esac
fi
case $prev in
-c|--config-file)
_filedir
return 0
;;
-t|--target-release|--default-release)
COMPREPLY=( $( apt-cache policy | \
command grep "release.o=Debian,a=$cur" | \
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-d -f -h -v -m -q -s -y -u -t -b -c -o
--download-only --fix-broken --help --version --ignore-missing
--fix-missing --no-download --quiet --simulate --just-print
--dry-run --recon --no-act --yes --assume-yes --show-upgraded
--only-source --compile --build --ignore-hold --target-release
--no-upgrade --force-yes --print-uris --purge --reinstall
--list-cleanup --default-release --trivial-only --no-remove
--diff-only --no-install-recommends --tar-only --config-file
--option --auto-remove' -- "$cur" ) )
else
COMPREPLY=( $( compgen -W 'list search show update install
remove upgrade full-upgrade edit-sources dist-upgrade
purge' -- "$cur" ) )
fi
return 0
} &&
complete -F _apt apt
# ex: ts=4 sw=4 et filetype=sh
Sau đó chạy source ~/.bashrcđể tải hoàn thành. Sau đó apt show firef+ Tabnên hoàn thành.
Điều này có thể cung cấp cho bạn các tùy chọn không còn tồn tại nữa. Tôi nghĩ rằng tôi đã đóng đinh các lệnh chính (có thể thay đổi theo thời gian) nhưng ít nhất nó sẽ giúp bạn với các lệnh phổ biến : list search show update install remove upgrade full-upgrade edit-sources dist-upgrade purge.
Rõ ràng, nếu một người duy trì hoàn thành bash muốn kiếm được những thứ ở trên, bạn sẽ được chào đón theo GPL (mặc dù tôi rất muốn bắt đầu lại từ khi mới aptđược ghi lại!)