Browse code

Added caching of packages

Max Persson authored on 07/12/2011 at 12:32:58
Showing 1 changed files
... ...
@@ -4,7 +4,10 @@
4 4
 # pip zsh completion, based on homebrew completion
5 5
 
6 6
 _pip_all() {
7
-  all_pkgs=(`pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'`)
7
+  # we cache the list of packages (originally from the macports plugin)
8
+  if (( ! $+piplist )); then
9
+	piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
10
+  fi
8 11
 }
9 12
 
10 13
 _pip_installed() {
... ...
@@ -62,7 +65,7 @@ case "$words[1]" in
62 62
      
63 63
       if [[ "$state" == packages ]]; then
64 64
         _pip_all
65
-        _wanted all_pkgs expl 'packages' compadd -a all_pkgs
65
+        _wanted piplist expl 'packages' compadd -a piplist
66 66
       fi ;;
67 67
   uninstall)
68 68
     _pip_installed