diff options
author | Arvid Norlander <702-vorpal@users.noreply.gitlab.archlinux.org> | 2022-05-22 12:32:50 +0200 |
---|---|---|
committer | Arvid Norlander <VorpalBlade@users.noreply.github.com> | 2022-05-23 08:58:29 +0200 |
commit | 8620ee52f926467ac08b58c4a04706ab4f7ea0c0 (patch) | |
tree | 6fd31b8a42bfc76be4d8ae36580fd63c8508ba3b | |
parent | f4e91e231cf158e4389f8dfc7e76a31f1bd613e4 (diff) |
Add zsh completion (implements issue #8)
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | completions/Makefile.am | 16 | ||||
-rw-r--r-- | completions/zsh/_checkupdates | 10 | ||||
-rw-r--r-- | completions/zsh/_paccache | 34 | ||||
-rw-r--r-- | completions/zsh/_pacdiff | 20 | ||||
-rw-r--r-- | completions/zsh/_paclist | 11 | ||||
-rw-r--r-- | completions/zsh/_paclog-pkglist | 11 | ||||
-rw-r--r-- | completions/zsh/_pacscripts | 15 | ||||
-rw-r--r-- | completions/zsh/_pacsearch | 12 | ||||
-rw-r--r-- | completions/zsh/_pacsort | 16 | ||||
-rw-r--r-- | completions/zsh/_pactree | 24 | ||||
-rw-r--r-- | completions/zsh/_rankmirrors | 17 | ||||
-rw-r--r-- | completions/zsh/_updpkgsums | 12 | ||||
-rw-r--r-- | configure.ac | 1 |
14 files changed, 200 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index fb3e64b..d9d163e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = src lib test +SUBDIRS = src lib test completions if WANT_DOC SUBDIRS += doc endif diff --git a/completions/Makefile.am b/completions/Makefile.am new file mode 100644 index 0000000..fbf10cd --- /dev/null +++ b/completions/Makefile.am @@ -0,0 +1,16 @@ + +zshcompletiondir = ${datadir}/zsh/site-functions/ + +zshcompletion_dir = ${zshcompletiondir} +zshcompletion__DATA = \ + zsh/_checkupdates \ + zsh/_paccache \ + zsh/_pacdiff \ + zsh/_paclist \ + zsh/_paclog-pkglist \ + zsh/_pacscripts \ + zsh/_pacsearch \ + zsh/_pacsort \ + zsh/_pactree \ + zsh/_rankmirrors \ + zsh/_updpkgsums diff --git a/completions/zsh/_checkupdates b/completions/zsh/_checkupdates new file mode 100644 index 0000000..ac6fc27 --- /dev/null +++ b/completions/zsh/_checkupdates @@ -0,0 +1,10 @@ +#compdef checkupdates + +declare -a args +args=( + '(--download -d)'{--download,-d}'[download pending updates to the pacman cache]' + '(-)'{--help,-h}'[display help message and exit]' + '(--nosync -n)'{--nosync,-n}'[do not sync the temporary database]' +) + +_arguments $args diff --git a/completions/zsh/_paccache b/completions/zsh/_paccache new file mode 100644 index 0000000..243149a --- /dev/null +++ b/completions/zsh/_paccache @@ -0,0 +1,34 @@ +#compdef paccache + +# TODO: Valid targets and --ignore values are package names in the cache. This +# is not the same as package names installed or available in sync. How do we +# generate this list? + +declare -a args +args=( + # Exlusive group + + '(operations)' + {--dryrun,-d}'[perform a dry run, only finding candidate packages]' + {--move,-m}'[move candidate packages to "dir"]:directory:_files -/' + {--remove,-r}'[remove candidate packages]' + + + options + '--min-atime[keep packages with an atime that is not older]:time: ' + '--min-mtime[keep packages with an mtime that is not older]:time: ' + '--nocolor[remove color from output]' + '(--arch -a)'{--arch=,-a+}'[scan for "arch" (default: all architectures)]:architecture: ' + '(--cachedir -c)'{--cachedir=,-c+}'[scan "dir" for packages. can be used more than once]:directory:_files -/' + '(--force -f)'{--force,-f}'[apply force to mv(1) and rm(1) operations]' + '(--ignore -i)'{--ignore=,-i+}'[ignore "pkgs", comma-separated, alternatively - for stdin]:pkgs: ' + '(--keep -k)'{--keep=,-k+}'[keep "num" of each package in the cache (default: 3)]:number: ' + '(--null -z)'{--null,-z}'[use null delimiters for candidate names (only with -v and -vv)]' + '(--quiet -q)'{--quiet,-q}'[[minimize output]' + '(--uninstalled -u)'{--uninstalled,-u}'[target uninstalled packages]' + '(-)'{--help,-h}'[display help message and exit]' + '(-)'{--version,-V}'[display version]' + '*'{--verbose,-v}'[increase verbosity. specify up to 3 times]' + + '*:targets: ' +) + +_arguments $args diff --git a/completions/zsh/_pacdiff b/completions/zsh/_pacdiff new file mode 100644 index 0000000..4f1cf2e --- /dev/null +++ b/completions/zsh/_pacdiff @@ -0,0 +1,20 @@ +#compdef pacdiff + +declare -a args +args=( + # Use a mutually exlusive group, indicated by parenthesis around group name + + '(search)' + {-f,--find}'[scan using find]' + {-l,--locate}'[scan using locate]' + {-p,--pacmandb}'[scan active config files from pacman database]' + + + options + '(-c --cachedir)'{-c,--cachedir}'[scan directory for 3-way merge base candidates]:directory:_files -/' + '--nocolor[remove colors from output]' + '(-o --output)'{-o,--output}'[print files instead of merging them]' + '(-s --sudo)'{-s,--sudo}'[use sudo to merge/remove files]' + '(-)'{--help,-h}'[display help message]' + '(-)--version[display version]' +) + +_arguments $args diff --git a/completions/zsh/_paclist b/completions/zsh/_paclist new file mode 100644 index 0000000..4e24b4d --- /dev/null +++ b/completions/zsh/_paclist @@ -0,0 +1,11 @@ +#compdef paclist + +declare -a args +args=( + '(-)'{--help,-h}'[show help message]' + '(-)'{--version,-V}'[show version]' + + '*:repository:{_values repository $(pacman-conf --repo-list)}' +) + +_arguments $args diff --git a/completions/zsh/_paclog-pkglist b/completions/zsh/_paclog-pkglist new file mode 100644 index 0000000..e97f8ae --- /dev/null +++ b/completions/zsh/_paclog-pkglist @@ -0,0 +1,11 @@ +#compdef paclog-pkglist + +declare -a args +args=( + '(-)'{--help,-h}'[show help message]' + '(-)'{--version,-V}'[show version]' + + '::pacman log file:_files' +) + +_arguments $args diff --git a/completions/zsh/_pacscripts b/completions/zsh/_pacscripts new file mode 100644 index 0000000..820c08c --- /dev/null +++ b/completions/zsh/_pacscripts @@ -0,0 +1,15 @@ +#compdef pacscripts + +_pacscripts_packages() { + _values package $(pacman -Slq) +} + +declare -a args +args=( + '(-)'{--help,-h}'[print help message]' + '(-)'{--version,-v}'[print program name and version]' + + ':package:{_alternative "packages:package:_pacscripts_packages" "files:pkgfile:_files"}' +) + +_arguments $args diff --git a/completions/zsh/_pacsearch b/completions/zsh/_pacsearch new file mode 100644 index 0000000..0e3d95d --- /dev/null +++ b/completions/zsh/_pacsearch @@ -0,0 +1,12 @@ +#compdef pacsearch + +declare -a args +args=( + '(--nocolor -n)'{--nocolor,-n}'[turn off coloring]' + '(-)'{--help,-h}'[display help message]' + '(-)'{--version,-V}'[display version]' + + ':pattern: ' +) + +_arguments $args diff --git a/completions/zsh/_pacsort b/completions/zsh/_pacsort new file mode 100644 index 0000000..aaaed9c --- /dev/null +++ b/completions/zsh/_pacsort @@ -0,0 +1,16 @@ +#compdef pacsort + +declare -a args +args=( + '(--files -f)'{--files,-f}'[assume inputs are file paths of packages]' + '(--key -k)'{--key,-k}'[sort input starting on specified column]:column index: ' + '(--null -z)'{--null,-z}'[lines end with null bytes, not newlines]' + '(--reverse -r)'{--reverse,-r}'[sort in reverse order (default: oldest to newest)]' + '(--separator -t)'{--separator,-t}'[specify field separator (default: space)]:field separator: ' + '(-)'{--help,-h}'[display help message]' + '(-)'{--version,-v}'[display the version]' + + '*:files:_files' +) + +_arguments $args diff --git a/completions/zsh/_pactree b/completions/zsh/_pactree new file mode 100644 index 0000000..fe71132 --- /dev/null +++ b/completions/zsh/_pactree @@ -0,0 +1,24 @@ +#compdef pactree + +declare -a args +args=( + '--config[set an alternate configuration file]:file:_files' + '--debug[display debug messages]' + '--gpgdir[set an alternate home directory for GnuPG]:directory:_files -/' + '(--ascii -a)'{--ascii,-a}'[use ASCII characters for tree formatting]' + '(--color -c)'{--color,-c}'[colorize output]' + '(--dbpath -b)'{--dbpath,-b}'[set an alternate database location]' + '(--depth -d)'{--depth,-d}'[limit the depth of recursion]:depth (number): ' + '(--graph -g)'{--graph,-g}'[generate output for graphviz'\''s dot]' + '(--linear -l)'{--linear,-l}'[enable linear output]' + '(--optional -o)'{--optional=-,-o-}'[controls at which depth to stop printing optional deps]::depth: ' + '(--reverse -r)'{--reverse,-r}'[list packages that depend on the named package]' + '(--sync -s)'{--sync,-s}'[search sync databases instead of local]' + '(--unique -u)'{--unique,-u}'[show dependencies with no duplicates (implies -l)]' + '(-)'{--help,-h}'[display help message]' + '(-)'{--version,-v}'[display the version]' + + '*:package:{_values "package" $(pacman -Qq)}' +) + +_arguments $args diff --git a/completions/zsh/_rankmirrors b/completions/zsh/_rankmirrors new file mode 100644 index 0000000..2892d89 --- /dev/null +++ b/completions/zsh/_rankmirrors @@ -0,0 +1,17 @@ +#compdef rankmirrors + +declare -a args +args=( + '-n[number of servers to output, 0 for all]:number of servers: ' + '(--max-time -m)'{--max-time,-m}'[specify a ranking operation timeout, can be decimal number]:timeout: ' + '(--repo -r)'{--repo,-r}'[specify a repository name instead of guessing]' + '(--times -t)'{--times,-t}'[only output mirrors and their response times]' + '(--url -u)'{--url,-u}'[test a specific UR]' + '(--verbose -v)'{--verbose,-v}'[be verbose in output]' + '(-)--version[show program'\''s version number and exit]' + '(-)'{--help,-h}'[show help message and exit]' + + ':mirror file or URL:{_alternative files:file:_files urls:url:_urls}' +) + +_arguments $args diff --git a/completions/zsh/_updpkgsums b/completions/zsh/_updpkgsums new file mode 100644 index 0000000..7ab94d1 --- /dev/null +++ b/completions/zsh/_updpkgsums @@ -0,0 +1,12 @@ +#compdef updpkgsums + +declare -a args +args=( + '(-)'{--help,-h}'[display help message and exit]' + '(--nocolor -m)'{--nocolor,-m}'[disable colorized output messages]' + '(-)'{--version,-V}'[display version information and exit]' + + '::build file:_files' +) + +_arguments $args diff --git a/configure.ac b/configure.ac index 0e1da80..761dbf5 100644 --- a/configure.ac +++ b/configure.ac @@ -159,6 +159,7 @@ else fi AC_CONFIG_FILES([ + completions/Makefile lib/Makefile src/Makefile doc/Makefile |