Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ install: lib
$(MAKE) -C doc/ $@
$(MAKE) -C lib/ $@
$(MAKE) -C src/ $@
$(MAKE) -C completion/ $@

clean:
$(MAKE) -C doc/ $@
Expand Down
25 changes: 25 additions & 0 deletions completion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
PREFIX ?= /usr/local
DATAROOTDIR ?= $(PREFIX)/share
ZSH_COMPLETION_DIR ?= $(DATAROOTDIR)/zsh/site-functions

ZSH_COMPLETION_FILES = \
zsh/_paccapability \
zsh/_paccheck \
zsh/_pacconf \
zsh/_pacfile \
zsh/_pacinfo \
zsh/_pacini \
zsh/_paclock \
zsh/_paclog \
zsh/_pacrepairdb \
zsh/_pacrepairfile \
zsh/_pacreport \
zsh/_pacsift \
zsh/_pacsync \
zsh/_pactrans

install:
install -d "${DESTDIR}${ZSH_COMPLETION_DIR}"
install -m 644 $(ZSH_COMPLETION_FILES) "${DESTDIR}${ZSH_COMPLETION_DIR}"

.PHONY: install
15 changes: 15 additions & 0 deletions completion/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
How to mostly autogenerate the zsh auto complete definitions

Write code like the following (using pacreport as an example):

dummy() { pacreport }
compdef _gnu_generic dummy
[tab complete "dummy -<tab>" once to cache results]
printf '%s\n' ${(onq-)_args_cache_dummy}

This will print entries to put in $args. After that, the following needs to be done manually:
* Completing arguments to flags (last optional field)
* Exlusivity (in leading parenthesis) & grouping of the flags.
* Repeatability (leading * after exlusivity)
* Handling any positional arguments.
* Any special handling (such as different modes, e.g. in pactrans or paclock).
9 changes: 9 additions & 0 deletions completion/zsh/_paccapability
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#compdef paccapability

declare -a args
args=(
'(-)--help[display help information]'
'(-)--version[display version information]'
'*:capability: '
)
_arguments $args
28 changes: 28 additions & 0 deletions completion/zsh/_paccheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#compdef paccheck

declare -a args
args=(
'--backup[include backup files in modification checks]'
'--config=[set an alternate configuration file]:<path>:_files'
'--db-files[include database files in checks]'
'--dbpath=[set an alternate database location]:<path>:_files'
'--depends[check for missing dependencies]'
'--file-properties[check installed files against MTREE data]'
'--files[check installed files against package database]'
'(-)--help[display help information]'
'--list-broken[only print packages that fail checks]'
'--md5sum[check file md5sums against MTREE data]'
'--noextract[include NoExtract files in modification checks]'
'--noupgrade[include NoUpgrade files in modification checks]'
'--null=[parse stdin as <sep> separated values (default NUL)]::<sep>: '
'--opt-depends[check for missing optional dependencies]'
'--quiet[only display error messages]'
'--recursive[perform checks on package (opt-)depends]'
'--require-mtree[treat packages missing MTREE data as an error]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sha256sum[check file sha256sums against MTREE data]'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'(-)--version[display version information]'
'*:packages:{_values packages $(pacman -Qq)}'
)
_arguments $args
19 changes: 19 additions & 0 deletions completion/zsh/_pacconf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#compdef pacconf

declare -a args
args=(
'--arch=[set an alternate architecture]:<arch>: '
'--config=[set an alternate configuration file]:<path>:_files'
'(-)--help[display help information]'
'--null=[use <sep> to separate values (default NUL)]::sep: '
'--options[display all global options]'
'--raw[display unmodified values]'
'(-)--repo-list[list configured repositories]'
'--repo=[query options for a specific repo]:<remote>:{_values repo $(pacconf --repo-list)}'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--single[only display the first value for list items]'
'--verbose[always show directive names]'
'(-)--version[display version information]'
'*:directive: '
)
_arguments $args
15 changes: 15 additions & 0 deletions completion/zsh/_pacfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#compdef pacfile

declare -a args
args=(
'--check[compare database values to filesystem]'
'--config=[set an alternate configuration file]:<path>:_files'
'--dbpath=[set an alternate database location]:<path>:_files'
'(-)--help[display help information]'
'--package=[limit information to specified package(s)]:<pkg>: '
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'(-)--version[display version information]'
'*:files:_files'
)
_arguments $args
21 changes: 21 additions & 0 deletions completion/zsh/_pacinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#compdef pacinfo

declare -a args
args=(
'--cachedir=[set an alternate cache location]:<path>:_path_files -/'
'--config=[set an alternate configuration file]:<path>:_files'
'--dbext=[set an alternate sync database extension]:<ext>: '
'--dbpath=[set an alternate database location]:<path>:_files'
'--debug[enable extra debugging messages]'
'(-)--help[display help information]'
'--no-timeout[disable low speed timeouts for downloads]'
'--null=[parse stdin as <sep> separated values (default NUL)]::sep: '
'--raw[display raw numeric values]'
'--removable-size[include removable dependencies in size]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--short[display brief package information]'
'--verbose[display additional package information]'
'(-)--version[display version information]'
'*:pkgspec:{_values pkgspec $(pacman -Sql)}'
)
_arguments $args
13 changes: 13 additions & 0 deletions completion/zsh/_pacini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#compdef pacini

declare -a args
args=(
'(-)--help[display help information]'
'(-)--section-list[list configured sections]'
'--section=[query options for a specific section]:<name>: '
'--verbose[always show directive names]'
'(-)--version[display version information]'
':file[File name]:_files'
'*:directives: '
)
_arguments $args
37 changes: 37 additions & 0 deletions completion/zsh/_paclock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#compdef paclock

local context state state_descr line ret=1
typeset -A opt_args
typeset -a args
args=(
'--config=[set an alternate configuration file]:<path>:_files'
'--dbpath=[set an alternate database location]:<path>:_files'
'--enoent-ok[ignore unlock errors due to a missing lock file]'
'--fail-ok[always unlock the database following --run]'
'--key=[set the lock identity key]:<id>: '
'--lock[establish a new lock (default)]'
'--lockfile=[set the lock file path]:<path>:_files'
'--no-check-keys[skip check for matching lock file key before unlocking]'
'--print[print the lock file path exit]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--run[run a command with the database locked]'
'--sysroot=[set an alternate installation system root]:<path>:_path_files -/'
'--unlock[remove an existing lock]'
'(-)--help[display help]'
'(-)--version[display version]'
)

if [[ $words[(ie)--run] -le ${#words} ]]; then
_arguments -S $args \
'*::arguments:->cmd' \
&& ret=0
else
_arguments -S $args \
&& ret=0
fi

if [[ $state == 'cmd' ]]; then
_normal && ret=0
fi

return ret
26 changes: 26 additions & 0 deletions completion/zsh/_paclog
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#compdef paclog

declare -a args
args=(
+ options
'(--no-color)--color[color output]'
'--config=[set an alternate configuration file]:<path>:_files'
'--debug[enable extra debugging messages]'
'--logfile=[set an alternate log file]:<path>:_files'
'(--color)--no-color[do not color output]'
'(filters)--pkglist[list installed packages (EXPERIMENTAL)]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate installation system root]:<path>:_path_files -/'
'(-)--help[show help and exit]'
'(-)--version[show version and exit]'
+ filters
'*--action=[show <action> entries]:<action>:(install reinstall upgrade downgrade remove all)'
'--after=[show entries after <date>]:<date>: '
'--before=[show entries before <date>]:<date>: '
'*--caller=[show entries from program <name>]:<name>: '
'--commandline[show command line entries]'
'*--grep=[show entries matching <regex>]:<regex>: '
'*--package=[show entries affecting <pkg>]:<pkg>:{_values package $(pacman -Sql)}'
'--warnings[show notes/warnings/errors]'
)
_arguments $args
24 changes: 24 additions & 0 deletions completion/zsh/_pacrepairdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#compdef pacrepairdb

declare -a args
args=(
'--cachedir=[set an alternate cache location]:<path>:_path_files -/'
'--config=[set an alternate configuration file]:<path>:_files'
'--dbonly[update database without reinstalling packages]'
'--dbpath=[set an alternate database location]:<path>:_files'
'--debug[enable extra debugging messages]'
'(-)--help[display help information]'
'--hookdir=[add additional user hook directory]:<path>:_path_files -/'
'--logfile=[set an alternate log file]:<path>:_files'
'--no-confirm[assume default responses to all prompts]'
'--no-hooks[do not run transaction hooks]'
'--no-scriptlet[do not run package install scripts]'
'--no-timeout[disable low speed timeouts for downloads]'
'--print-only[show steps without performing them]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'--verbose[display additional progress information]'
'(-)--version[display version information]'
'*:packages:{_values packages $(pacman -Qq)}'
)
_arguments $args
19 changes: 19 additions & 0 deletions completion/zsh/_pacrepairfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#compdef pacrepairfile

declare -a args
args=(
'--config=[set an alternate configuration file]:<path>:_files'
'--dbpath=[set an alternate database location]:<path>:_files'
'--gid[set file group id]'
'(-)--help[display help information]'
'--mode[set file permissions]'
'--mtime[set file modification time]'
'--package=[search package <name> for file properties]:<name>:{_values package $(pacman -Qq)}'
'--quiet[do not display progress information]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'--uid[set file owner id]'
'(-)--version[display version information]'
'*:files:_files'
)
_arguments $args
19 changes: 19 additions & 0 deletions completion/zsh/_pacreport
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#compdef pacreport

declare -a args
args=(
'--backups[list .pac{save,orig,new} files]'
'--cachedir=[set an alternate cache location]:<path>:_path_files -/'
'--config=[set an alternate pacman configuration file]:<path>:_files'
'--dbext=[set an alternate sync database extension]:<ext>: '
'--dbpath=[set an alternate database location]:<path>:_files'
'*--group=[list missing group packages]:<group>:{_values group $(pacman -Sg)}'
'(-)--help[display help information]'
'--missing-files[list missing package files]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'--unowned-files[list unowned files]'
'--optional-deps[take optional dependencies into account when listing unneeded packages and dependency loops]'
'(-)--version[display version information]'
)
_arguments $args
47 changes: 47 additions & 0 deletions completion/zsh/_pacsift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#compdef pacsift

declare -a args
args=(
+ options
'--any[display packages matching any search criteria]'
'--build-date=[search package build date]:<val>: '
'--config=[set an alternate configuration file]:<path>:_files'
'--dbext=[set an alternate sync database extension]:<ext>: '
'--dbpath=[set an alternate database location]:<path>:_files'
'--exact[match search terms exactly]'
'(--not-exists)--exists[exit with a non-zero value if no matches were found]'
'(-)--help[display help information]'
'--invert[display packages which DO NOT match search criteria]'
'(--exists)--not-exists[exit with a non-zero value if matches were found]'
'--null=[use <sep> to separate values (default NUL)]::sep: '
'--regex[use regular expressions for matching]'
'--root=[set an alternate installation root]:<path>:_path_files -/'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'(-)--version[display version information]'
+ filters
'--cache[search packages in cache (EXPERIMENTAL)]'
'--local[search installed packages]'
'--sync[search packages in all sync repositories]'
+ package-fields
'*--architecture=[search package architecture]:<val>: '
'*--base=[search package bases]:<val>: '
'*--repo=[search packages in repo <name>]:<val>:{_values repo $(pacconf --repo-list)}'
'*--name=[search package names]:<val>:{_values name $(pacman -Sql)}'
'*--description=[search package descriptions]:<val>: '
'*--packager=[search package packager field]:<val>: '
'*--group=[search package group field]:<val>:{_values group $(pacman -Sg)}'
'*--owns-file=[search package file lists]:<val>:_files'
'*--license=[search package licenses]:<val>: '
'*--provides=[search package provides]:<val>:{_values package $(pacman -Sql)}'
'*--depends=[search package dependencies]:<val>:{_values package $(pacman -Sql)}'
'*--optdepends=[search package dependencies]:<val>:{_values package $(pacman -Sql)}'
'*--conflicts=[search package conflicts]:<val>: '
'*--replaces=[search package replaces]:<val>:{_values package $(pacman -Sql)}'
'*--install-date=[search package install date]:<val>: '
'*--installed-size=[search package installed size]:<val>: '
'*--download-size=[search package download size]:<val>: '
'*--size=[search package size]:<val>: '
'*--url=[search package url]:<val>: '
'*--satisfies=[find packages satisfying dependency <val>]:<val>: '
)
_arguments $args
18 changes: 18 additions & 0 deletions completion/zsh/_pacsync
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#compdef pacsync

declare -a args
args=(
'--config=[set an alternate configuration file]:<path>:_files'
'--dbext=[set an alternate sync database extension]:<ext>: '
'--dbpath=[set an alternate database location]:<path>:_files'
'--debug[enable extra debugging messages]'
'--force[sync repos even if already up-to-date]'
'(-)--help[display help information]'
'--logfile=[set an alternate log file]:<path>:_files'
'--no-timeout[disable low speed timeouts for downloads]'
'--sysroot=[set an alternate system root]:<path>:_path_files -/'
'--updated[return false unless a database was updated]'
'(-)--version[display version information]'
'*:repo:{_values repo $(pacconf --repo-list)}'
)
_arguments $args
Loading