Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: apt autocompletion issue
- X-seq: zsh-workers 44614
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx, pkg-zsh-devel@xxxxxxxxxxxxxxxxxxxxxxx
- Subject: Re: apt autocompletion issue
- Date: Wed, 31 Jul 2019 00:13:03 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1564524784; bh=K/mZTtpJrS56cA0sCjQQTJcS0DLG+Zbfpau4RXxevYA=; h=From:References:To:Subject:Date:From:Subject; b=VhPQWR30XsT//VAfqlTEVpfp6xl4vuUr+YXxqwIxch4vz91BeSPVgcgl8z64lsZHS8K2g62vDbP+619kHnlsBHLSyEGA91POjCmEVQbUgNXSYE/NkSgIGobL9PdXjEwZ3nwJ2FncZ3PCRrVW9x1jMvSl5vHdDhZCXpY+VxzAMhXNvW62BI5a3iQ5AdkBB8vT931Bnj36MIT/WQMXs799UAA3Sr7mALPD1Rkw3wLqnzlDpG9+mwoCHPvcfVmLiTHRXFZ/6IlLt4KOhVlyQdgwG/oh34hadU7CsFzs8Pq+jdrh+5HWypVZUnSea4m1j3zIYbgIS7WRJFP7Yn8WfcXy2A==
- In-reply-to: <20190730145353.k2eonyy6w2z7luau@sym.noone.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20190730145353.k2eonyy6w2z7luau@sym.noone.org>
Axel Beckert wrote:
> TL;DR: I recommend to just complete all packages upon
> "apt list --upgradable <Tab>".
Thanks, so this updated patch uses installed with --installed and avail
otherwise. After checking the man page, I also added completion of
reinstall and auto-removal for - and + suffixes.
> > On 26 Jul, "Hauser, Felix (MRT)" wrote:
> > > which is easily done in the normal bash file.
Just for note Felix, while technically possible, I'd really recommend
against trying to ever use bash completions with zsh.
> Daniel Shahaf wrote:
> > ??aptitude search -F %p '?upgradable'?? would print the right set of
> > packages, I think, but aptitude isn't part of a minimal installation so
> > can't be assumed available.
A _deb_packages_update_upgradable function could check
(( $+commands[aptitude] )) and offer all packages as a fallback.
Or one of the options Axel mentions - if someone wants to do that.
> > Cc += Debian zsh packagers.
>
> Thanks. I read Felix initial mail, but just adding three hard coded
> long options seemed rather trivial...
It's often not as trivial as it might first seem without a copy of the
command to test combinations against. I probably need to install yet
another VM to cover Debian given a large number of Debian specific
completions. Out of interest, what is the recommended apt* tool these
days? Is aptitude the best or most powerful with apt as the simplified
interface and apt-get just a historic relic?
Oliver
diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt
index 4486aa26d..4d60cd249 100644
--- a/Completion/Debian/Command/_apt
+++ b/Completion/Debian/Command/_apt
@@ -399,7 +399,13 @@ _apt-cmd () {
-o,--option:arbitem \
-t,--target-release:release \
-- \
- /$'list\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
+ /$'list\0'/ \( \
+ \( \
+ /$'--installed\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# /'[]'/ \| \
+ // %-% /$'--[^\0]#\0'/ ':options:option:(--installed --upgradable --all-versions)' \
+ \| \) \
+ /$'[^-\0][^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \
+ \) \| \
/$'search\0'/ /$'[^\0]#\0'/ ':strings:pattern:' \| \
/$'showsrc\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
/$'show\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
@@ -409,15 +415,14 @@ _apt-cmd () {
/$'update\0'/ \| \
\( \
/$'(install|download|source|build-dep)\0'/ -'subcmd=${match%?}' \
- /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=" "$expl_packages[@]" avail' \# \
+ /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=+-" "$expl_packages[@]" avail' \# \
\( \
// '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files -c' \| \
/$'[^\0/=]#\/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \
/$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \| \
\) \
\) \| \
- /$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
- /$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
+ /$'(remove|reinstall|purge)\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'upgrade\0'/ \| \
/$'autoclean\0'/ \| \
/$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \
@@ -425,7 +430,7 @@ _apt-cmd () {
/$'full-upgrade\0'/ \| \
/$'dist-upgrade\0'/ \| \
/$'edit-sources\0'/ \| \
- /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge'
+ /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge'
_apt-cmd () {
local expl_action expl_packages subcmd
Messages sorted by:
Reverse Date,
Date,
Thread,
Author