Browse code

Optimize plugin loading so that only one call to compinit is required

Pat Regan authored on 12/04/2011 at 21:41:09
Showing 8 changed files
... ...
@@ -10,14 +10,23 @@ for config_file ($ZSH/lib/*.zsh) source $config_file
10 10
 # Load all of your custom configurations from custom/
11 11
 for config_file ($ZSH/custom/*.zsh) source $config_file
12 12
 
13
-# Load all of the plugins that were defined in ~/.zshrc
13
+# Add all defined plugins to fpath
14 14
 plugin=${plugin:=()}
15
-for plugin ($plugins) source $ZSH/plugins/$plugin/$plugin.plugin.zsh
15
+for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath)
16 16
 
17 17
 # Load and run compinit
18 18
 autoload -U compinit
19 19
 compinit -i
20 20
 
21
+# Load all of the plugins that were defined in ~/.zshrc
22
+for plugin ($plugins)
23
+do
24
+  if [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]
25
+  then
26
+    source $ZSH/plugins/$plugin/$plugin.plugin.zsh
27
+  fi
28
+done
29
+
21 30
 # Load the theme
22 31
 source "$ZSH/themes/$ZSH_THEME.zsh-theme"
23 32
 
24 33
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# add brew completion function to path
2
-fpath=($ZSH/plugins/brew $fpath)
3 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# add cpanm completion function to path
2
-fpath=($ZSH/plugins/cpanm $fpath)
3 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# add gem completion function to path
2
-fpath=($ZSH/plugins/gem $fpath)
3 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# add github completion function to path
2
-fpath=($ZSH/plugins/github $fpath)
... ...
@@ -6,5 +6,3 @@ alias puni="sudo port uninstall inactive"
6 6
 alias puo="sudo port upgrade outdated"
7 7
 alias pup="psu && puo"
8 8
 
9
-# add macports completion function to path
10
-fpath=($ZSH/plugins/macports $fpath)
11 9
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# add brew completion function to path
2
-fpath=($ZSH/plugins/pip $fpath)
3 1
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-fpath=($ZSH/plugins/vagrant $fpath)