2012-06-16 00:30:10 +00:00
|
|
|
function __fish_complete_pacman -d 'Complete pacman (ARCH package manager)' --argument-names progname
|
2012-10-01 14:41:29 +00:00
|
|
|
# Completions for pacman
|
2012-06-16 00:30:10 +00:00
|
|
|
# Author: Giorgio Lando <patroclo7@gmail.com>
|
2012-10-01 14:41:29 +00:00
|
|
|
# Updated by maxfl, SanskritFritz.
|
|
|
|
|
2012-06-16 00:30:10 +00:00
|
|
|
set -q progname[1]; or set -l progname pacman
|
|
|
|
|
2012-10-01 14:41:29 +00:00
|
|
|
set -l listinstalled "(pacman -Q | tr ' ' \t)"
|
2014-02-07 05:55:53 +00:00
|
|
|
set -l listall "(__fish_print_packages)"
|
2012-10-01 14:41:29 +00:00
|
|
|
set -l listrepos "(cat /etc/pacman.conf | grep '^\[.\+\]' | sed 's/[]\[]//g')"
|
|
|
|
set -l listgroups "(pacman -Sg | sed 's/\(.*\)/\1\tPackage group/g')"
|
|
|
|
|
2012-10-02 14:21:08 +00:00
|
|
|
set -l noopt 'commandline | not sgrep -qe "-[a-z]*[DQRSTU]\|--database\|--query\|--sync\|--remove\|--upgrade\|--deptest"'
|
|
|
|
set -l database 'commandline | sgrep -qe "-[a-z]*D\|--database"'
|
|
|
|
set -l query 'commandline | sgrep -qe "-[a-z]*Q\|--query"'
|
|
|
|
set -l remove 'commandline | sgrep -qe "-[a-z]*R\|--remove"'
|
|
|
|
set -l sync 'commandline | sgrep -qe "-[a-z]*S\|--sync"'
|
|
|
|
set -l upgrade 'commandline | sgrep -qe "-[a-z]*U\|--upgrade"'
|
2012-06-16 00:30:10 +00:00
|
|
|
|
2012-10-01 14:41:29 +00:00
|
|
|
# By default fish expands the arguments with the option which is not desired
|
|
|
|
# due to performance reasons.
|
|
|
|
# This will make sure we are expanding an argument and not an option:
|
|
|
|
set -l argument 'not expr -- (commandline --current-token) : "^-.*" > /dev/null'
|
2012-06-16 00:30:10 +00:00
|
|
|
|
|
|
|
# Primary operations
|
|
|
|
complete -c $progname -s D -f -l database -n $noopt -d 'Modify the package database'
|
|
|
|
complete -c $progname -s Q -f -l query -n $noopt -d 'Query the package database'
|
|
|
|
complete -c $progname -s R -f -l remove -n $noopt -d 'Remove packages from the system'
|
|
|
|
complete -c $progname -s S -f -l sync -n $noopt -d 'Synchronize packages'
|
|
|
|
complete -c $progname -s T -f -l deptest -n $noopt -d 'Check dependencies'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -s U -f -l upgrade -n $noopt -d 'Upgrade or add a local package'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -s V -f -l version -d 'Display version and exit'
|
|
|
|
complete -c $progname -s h -f -l help -d 'Display help'
|
|
|
|
|
|
|
|
# General options
|
|
|
|
complete -c $progname -s b -l dbpath -d 'Alternative database location' -xa '(__fish_complete_directories)'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -s r -l root -d 'Alternative installation root'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -s v -l verbose -d 'Output more status messages'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -l arch -d 'Alternate architecture'
|
|
|
|
complete -c $progname -l cachedir -d 'Alternative package cache location'
|
2013-04-01 17:49:02 +00:00
|
|
|
complete -c $progname -l config -d 'Alternate config file'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -l debug -d 'Display debug messages'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -l gpgdir -d 'GPG directory to verify signatures'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -l logfile -d 'Specify alternative log file'
|
|
|
|
complete -c $progname -l noconfirm -d 'Bypass any question'
|
2012-10-01 14:41:29 +00:00
|
|
|
|
2012-10-02 14:21:08 +00:00
|
|
|
# Transaction options (sync, remove, upgrade)
|
|
|
|
for condition in sync remove upgrade
|
|
|
|
complete -c $progname -n $$condition -s d -l nodeps -d 'Skip [all] dependency checks'
|
|
|
|
complete -c $progname -n $$condition -l dbonly -d 'Modify database entry only'
|
2013-04-01 17:49:02 +00:00
|
|
|
complete -c $progname -n $$condition -l noprogressbar -d 'Do not display progress bar'
|
|
|
|
complete -c $progname -n $$condition -l noscriptlet -d 'Do not execute install script'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $$condition -s p -l print -d 'Dry run, only print targets'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $$condition -l print-format -x -d 'Specify printf-like format'
|
|
|
|
end
|
2012-10-01 14:41:29 +00:00
|
|
|
|
2012-10-02 14:21:08 +00:00
|
|
|
# Database and upgrade options (database, sync, upgrade)
|
|
|
|
for condition in database sync upgrade
|
|
|
|
complete -c $progname -n $$condition -l asdeps -d 'Mark PACKAGE as dependency'
|
|
|
|
complete -c $progname -n $$condition -l asexplicit -d 'Mark PACKAGE as explicitly installed'
|
|
|
|
end
|
|
|
|
|
2012-06-16 00:30:10 +00:00
|
|
|
# Upgrade options (sync, upgrade)
|
|
|
|
for condition in sync upgrade
|
|
|
|
complete -c $progname -n $$condition -s f -l force -d 'Bypass file conflict checks'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $$condition -l ignore -d 'Ignore upgrade of PACKAGE' -xa "$listinstalled"
|
|
|
|
complete -c $progname -n $$condition -l ignoregroup -d 'Ignore upgrade of GROUP' -xa "$listgroups"
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $$condition -l needed -d 'Do not reinstall up-to-date targets'
|
|
|
|
complete -c $progname -n $$condition -l recursive -d 'Recursively reinstall all dependencies'
|
|
|
|
end
|
2012-10-01 14:41:29 +00:00
|
|
|
|
2012-06-16 00:30:10 +00:00
|
|
|
# Query and sync options
|
|
|
|
for condition in query sync
|
2012-11-18 10:23:22 +00:00
|
|
|
complete -c $progname -n $$condition -s g -l groups -d 'Display all packages in GROUP' -xa "$listgroups"
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $$condition -s i -l info -d 'Display information on PACKAGE'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $$condition -s q -l quiet -d 'Show less information'
|
|
|
|
complete -c $progname -n $$condition -s s -l search -r -d 'Search packages for regexp'
|
|
|
|
end
|
|
|
|
|
|
|
|
# Query options
|
2013-04-01 17:49:02 +00:00
|
|
|
complete -c $progname -n $query -s c -l changelog -d 'View the change log of PACKAGE'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $query -s d -l deps -d 'List only non-explicit packages (dependencies)'
|
|
|
|
complete -c $progname -n $query -s e -l explicit -d 'List only explicitly installed packages'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $query -s k -l check -d 'Check if all files owned by PACKAGE are present'
|
|
|
|
complete -c $progname -n $query -s l -l list -d 'List all files owned by PACKAGE'
|
|
|
|
complete -c $progname -n $query -s m -l foreign -d 'List all packages not in the database'
|
|
|
|
complete -c $progname -n $query -s o -l owns -r -d 'Search for the package that owns FILE' -xa ''
|
|
|
|
complete -c $progname -n $query -s p -l file -d 'Apply the query to a package file, not package' -xa ''
|
|
|
|
complete -c $progname -n $query -s t -l unrequired -d 'List only unrequired packages'
|
|
|
|
complete -c $progname -n $query -s u -l upgrades -d 'List only out-of-date packages'
|
2014-02-07 05:55:53 +00:00
|
|
|
complete -c $progname -n "$query; and $argument" -d 'Installed package' -xa $listinstalled
|
2012-10-01 14:41:29 +00:00
|
|
|
|
2012-06-16 00:30:10 +00:00
|
|
|
# Remove options
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $remove -s c -l cascade -d 'Also remove packages depending on PACKAGE'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $remove -s n -l nosave -d 'Ignore file backup designations'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $remove -s s -l recursive -d 'Also remove dependencies of PACKAGE'
|
|
|
|
complete -c $progname -n $remove -s u -l unneeded -d 'Only remove targets not required by PACKAGE'
|
2014-02-07 05:55:53 +00:00
|
|
|
complete -c $progname -n "$remove; and $argument" -d 'Installed package' -xa $listinstalled
|
2012-06-16 00:30:10 +00:00
|
|
|
|
|
|
|
# Sync options
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $sync -s c -l clean -d 'Remove [all] packages from cache'
|
|
|
|
complete -c $progname -n $sync -s l -l list -xa "$listrepos" -d 'List all packages in REPOSITORY'
|
2012-06-16 00:30:10 +00:00
|
|
|
complete -c $progname -n $sync -s u -l sysupgrade -d 'Upgrade all packages that are out of date'
|
|
|
|
complete -c $progname -n $sync -s w -l downloadonly -d 'Only download the target packages'
|
2012-10-02 14:21:08 +00:00
|
|
|
complete -c $progname -n $sync -s y -l refresh -d 'Download fresh copy of the package list'
|
2012-10-01 14:41:29 +00:00
|
|
|
complete -c $progname -n "$argument; and $sync" -xa "$listall $listgroups"
|
2012-06-16 00:30:10 +00:00
|
|
|
|
|
|
|
# Upgrade options
|
2012-10-01 14:41:29 +00:00
|
|
|
complete -c $progname -n "$upgrade; and $argument" -xa '(__fish_complete_suffix pkg.tar.xz)' -d 'Package file'
|
|
|
|
complete -c $progname -n "$upgrade; and $argument" -xa '(__fish_complete_suffix pkg.tar.gz)' -d 'Package file'
|
2012-06-16 00:30:10 +00:00
|
|
|
end
|
2012-10-02 14:21:08 +00:00
|
|
|
|