Complete the pacapt completion
* the completion function was not formulated properly
This commit is contained in:
parent
7e33cb16f3
commit
f8cda1867b
39
src/_pacapt
39
src/_pacapt
|
@ -1,14 +1,8 @@
|
||||||
#compdef pacapt
|
#compdef pacapt
|
||||||
|
|
||||||
local zsh_pacapt_path="$(cd "$(dirname "$0")" && pwd)"
|
_pacapt(){
|
||||||
|
# ----- APT
|
||||||
_pacapt_action() {
|
if which apt > /dev/null; then
|
||||||
_arguments -s : \
|
|
||||||
"$_pacapt_opts_commands[@]"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ----- APT
|
|
||||||
if which apt > /dev/null; then
|
|
||||||
zsh_pacapt_init=true
|
zsh_pacapt_init=true
|
||||||
|
|
||||||
_pacapt_available_packages() {
|
_pacapt_available_packages() {
|
||||||
|
@ -19,8 +13,8 @@ if which apt > /dev/null; then
|
||||||
_values 'Installed packages' $(pacapt -Q | awk '{print $2}')
|
_values 'Installed packages' $(pacapt -Q | awk '{print $2}')
|
||||||
}
|
}
|
||||||
|
|
||||||
# ----- YUM
|
# ----- YUM
|
||||||
elif which yum > /dev/null; then
|
elif which yum > /dev/null; then
|
||||||
zsh_pacapt_init=true
|
zsh_pacapt_init=true
|
||||||
|
|
||||||
_pacapt_yum_list() {
|
_pacapt_yum_list() {
|
||||||
|
@ -34,8 +28,8 @@ elif which yum > /dev/null; then
|
||||||
_pacapt_installed_packages() {
|
_pacapt_installed_packages() {
|
||||||
_pacapt_yum_list installed
|
_pacapt_yum_list installed
|
||||||
}
|
}
|
||||||
# ----- BREW
|
# ----- BREW
|
||||||
elif which brew > /dev/null; then
|
elif which brew > /dev/null; then
|
||||||
zsh_pacapt_init=true
|
zsh_pacapt_init=true
|
||||||
|
|
||||||
_pacapt_available_packages() {
|
_pacapt_available_packages() {
|
||||||
|
@ -45,9 +39,9 @@ elif which brew > /dev/null; then
|
||||||
_pacapt_installed_packages() {
|
_pacapt_installed_packages() {
|
||||||
_values 'Installed packages' $(brew list)
|
_values 'Installed packages' $(brew list)
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_pacapt_zsh_comp() {
|
_pacapt_zsh_comp() {
|
||||||
case $words[2] in
|
case $words[2] in
|
||||||
-Qi) _pacapt_available_packages ;;
|
-Qi) _pacapt_available_packages ;;
|
||||||
-Qo) _files ;;
|
-Qo) _files ;;
|
||||||
|
@ -58,11 +52,12 @@ _pacapt_zsh_comp() {
|
||||||
- ) _gnu_generic ;;
|
- ) _gnu_generic ;;
|
||||||
* ) return 1 ;;
|
* ) return 1 ;;
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if "$zsh_pacapt_init" = true; then
|
||||||
|
_pacapt_zsh_comp $@
|
||||||
|
else
|
||||||
|
_gnu_generic $@
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if "$zsh_pacapt_init" = true; then
|
|
||||||
compdef _pacapt_zsh_comp pacapt
|
|
||||||
else
|
|
||||||
compdef _gnu_generic pacapt
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue