summaryrefslogtreecommitdiff
path: root/etc/completions/_pkg
blob: 8a621a6eb2c37ac3c9861844aa97f1c3f1b94607 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#compdef pkg
## vim:ft=zsh
## pkg completion
## Daniel Friesel <derf@derf.homelinux.org>
## https://derf.homelinux.org/~derf/dotfiles/zsh/completions/_pkg
## see also: https://derf.homelinux.org/~derf/code/lighty-stats

local arguments_action arguments_list arguments_listall
local all installed

all='pkg list-all'
installed='pkg list'
notinstalled='diff <(eval $installed) <(eval $all) | grep "^>" | cut -d " " -f 2'

arguments_action=(
	'1:action:(add install changelog changeroot check delete remove info list list-all local-update log push remote-update status update upgrade)'
)
arguments_list=(
	'2:package:($(eval $installed))'
)
arguments_listall=(
	'2:package:($(eval $all))'
)
arguments_notinstalled=(
	'2:package:($(eval $notinstalled))'
)

if [[ $CURRENT -ge 3 ]] {
	case ${words[2]} in
		changelog|check|delete|log|push|remove|status|upgrade) _arguments -s $arguments_list ;;
		info) _arguments -s $arguments_listall ;;
		add|install) _arguments -s $arguments_notinstalled ;;
	esac
} else {
	_arguments -s $arguments_action
}