DRY up my *env plugins

Tue, 21 Jul 2015 00:50:59 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 21 Jul 2015 00:50:59 -0400
changeset 195
390c49ee432d
parent 194
39bb7938cf9f
child 196
29fce4f498e5

DRY up my *env plugins

.zshrc file | annotate | diff | comparison | revisions
--- a/.zshrc
+++ b/.zshrc
@@ -8,6 +8,7 @@ DISABLE_AUTO_UPDATE="true"
 # DISABLE_UPDATE_PROMPT="true"
 
 plugins=( common-aliases gitfast )
+envthings=( plenv rbenv ndenv )
 
 if [ -f ~/.zshrc.local-pre ]; then
   source ~/.zshrc.local-pre
@@ -39,15 +40,12 @@ source ~/.profile.common
 
 typeset -U path
 
-if [ -d ~/.plenv ]; then
-  path=( ~/.plenv/bin "$path[@]" )
-  eval "$(plenv init - zsh)"
-fi
-
-if [ -d ~/.rbenv ]; then
-  path=( ~/.rbenv/bin "$path[@]" )
-  eval "$(rbenv init - zsh)"
-fi
+for ENVTHING in $envthings; do
+  if [ -d ~/.$ENVTHING ]; then
+    path=( ~/.$ENVTHING/bin "$path[@]" )
+    eval "$($ENVTHING init - zsh)"
+  fi
+done
 
 if [ -f ~/.zshrc.local ]; then
   source ~/.zshrc.local

mercurial