-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_zypper
More file actions
executable file
·76 lines (71 loc) · 1.86 KB
/
Copy path_zypper
File metadata and controls
executable file
·76 lines (71 loc) · 1.86 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#compdef zypper
#
# zsh completion for 'zypper' package manager (openSuse)
#
# Copyright (C) 2013 Mattis Michel <sic_zer0@hotmail.com>
#
_zypper() {
if (( CURRENT > 2 )); then
local cmd=${words[2]}
case "$cmd" in
'install') _zypper_all ;;
'in') _zypper_all ;;
'info') _zypper_all ;;
'if') _zypper_all ;;
'search') _zypper_all ;;
'se') _zypper_all ;;
'update') _zypper_installed ;;
'up') _zypper_installed ;;
'remove') _zypper_installed ;;
'rm') _zypper_installed ;;
esac
else
compadd install info remove search
fi
}
_zypper_all() {
local update=0
typeset -gA _zyppercomp_repodates # global
for d in /var/cache/zypp/raw/*; do
local pkgs=$d/suse/setup/descr/packages.gz;
if [[ -e $pkgs ]]; then
local newdate=`stat -c "%Z" $pkgs`
if [[ "$_zyppercomp_repodates[$pkgs]" != "$newdate" ]]; then
_zyppercomp_repodates[$pkgs]="$newdate"
update=1
fi
fi
for f in $d/repodata/*primary.xml.gz; do
local newdate=`stat -c "%Z" $f`
if [[ "$_zyppercomp_repodates[$f]" != "$newdate" ]]; then
_zyppercomp_repodates[$f]="$newdate"
update=1
fi
done
done
if (( update == 1 )); then
_zypper_update_repos
fi
compadd $(echo $_zyppercomp_packages)
}
_zypper_installed() {
local newdate=`stat -c "%Z" /var/lib/rpm/Packages`
if [[ "$_zyppercomp_rpm_date" != "$newdate" ]]; then
_zyppercomp_rpm_list=`rpm -qa` # global
_zyppercomp_rpm_date="$newdate" # global
fi
compadd $(echo $_zyppercomp_rpm_list)
}
_zypper_update_repos() {
local packages
for d in /var/cache/zypp/raw/*; do
local pkgs=$d/suse/setup/descr/packages.gz;
if [[ -e $pkgs ]]; then
packages=($packages `gunzip -c $pkgs | sed -n 's/^=Pkg:\s\s*\([^ ]*\).*$/\1/p'`)
fi
for f in $d/repodata/*primary.xml.gz; do
packages=($packages `gunzip -c $f | sed -n 's/.*<name>\(.*\)<\/name>.*/\1/p'`)
done
done
_zyppercomp_packages=$packages # global
}