fa344733e5d7cee33e4c3ba6a9a7241c7b6377ca
- Author
- Matt Cable <wozz@wookie.net>
- Committer
- Matt Cable <wozz@wookie.net>
- Date
Message
Add completion for port command
Diff
1diff --git a/plugins/macports/_port b/plugins/macports/_port
2new file mode 100644
3index 0000000000000000000000000000000000000000..06d7fb426cc8c5374720845a3c91d6591a17e0fd
4--- /dev/null
5+++ b/plugins/macports/_port
6@@ -0,0 +1,89 @@
7+#compdef port
8+
9+local subcmds
10+
11+# we cache the list of ports
12+# we shall use some cache policy to avoid problems with new ports
13+if (( ! $+portlist )); then
14+ portlist=($(port echo all; echo "all current active inactive installed uninstalled outdated"))
15+fi
16+
17+subcmds=(
18+'activate'
19+'archive'
20+'build'
21+'cat'
22+'clean'
23+'configure'
24+'contents'
25+'deactivate'
26+'dependents'
27+'deps'
28+'destroot'
29+'dir'
30+'distcheck'
31+'distclean'
32+'dmg'
33+'echo'
34+'edit'
35+'extract'
36+'fetch'
37+'file'
38+'help'
39+'info'
40+'install'
41+'installed'
42+'list'
43+'livecheck'
44+'location'
45+'mpkg'
46+'outdated'
47+'patch'
48+'pkg'
49+'provides'
50+'rpmpackage'
51+'search'
52+'selfupdate'
53+'sync'
54+'test'
55+'unarchive'
56+'uninstall'
57+'upgrade'
58+'variants'
59+'version'
60+)
61+
62+_arguments -C \
63+'-v[verbose mode (generate verbose messages)]' \
64+'-d[debug mode (generate debugging messages)]' \
65+'-q[quiet mode (suppress messages)]' \
66+'-D[specify portdir]' \
67+'-k[keep mode (do not autoclean after install)]' \
68+'-n[dont follow dependencies in upgrade (only for upgrading)]' \
69+'-a[upgrade all installed ports (only for upgrading)]' \
70+'-u[uninstall non-active ports when upgrading and uninstalling]' \
71+'-f[force mode (ignore state file)]' \
72+'-s[source-only mode]' \
73+'-b[binary-only mode]' \
74+'-o[honor state files older than Portfile]' \
75+'*::command:->command' \
76+&& return 0
77+
78+case $state in
79+ command)
80+ if ((CURRENT == 1)); then
81+ state=subcommands
82+ else
83+ state=portname
84+ fi
85+ ;;
86+esac
87+
88+case $state in
89+ subcommands)
90+ _describe -t commands 'port commands' subcmds
91+ ;;
92+ portname)
93+ _describe -t commands 'available ports' portlist
94+ ;;
95+esac
96diff --git a/plugins/macports/macports.plugin.zsh b/plugins/macports/macports.plugin.zsh
97index 9564829b036373ce405dd17c61936a9b5ab4184d..cbbc4926596480a1567ae5b36e812412c3c901d3 100644
98--- a/plugins/macports/macports.plugin.zsh
99+++ b/plugins/macports/macports.plugin.zsh
100@@ -5,3 +5,8 @@ alias psu="sudo port selfupdate"
101 alias puni="sudo port uninstall inactive"
102 alias puo="sudo port upgrade outdated"
103 alias pup="psu && puo"
104+
105+# add macports completion function to path
106+fpath=($ZSH/plugins/macports $fpath)
107+autoload -U compinit
108+compinit -i