From c641f7793c1377f78fcdedfde7e4e61268d6d6a0 Mon Sep 17 00:00:00 2001 From: Michael Komitee Date: Sat, 15 Jan 2011 14:55:46 -0500 Subject: [PATCH] Adding mechanism for managing paths in a plugin. * User creates a file (by default ~/.pathrc) which lists one directory per line, all of the directories which should make up his path. The file to use can be overridden with the PATHRC variable. * User creates a file (by default ~/.manpathrc) which lists one directory per line, all of the directories which should make up his manpath. The file to use can be overridden with the MANPATHRC variable. --- plugins/pathrc/pathrc.plugin.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/pathrc/pathrc.plugin.zsh diff --git a/plugins/pathrc/pathrc.plugin.zsh b/plugins/pathrc/pathrc.plugin.zsh new file mode 100644 index 000000000..c953ef5aa --- /dev/null +++ b/plugins/pathrc/pathrc.plugin.zsh @@ -0,0 +1,27 @@ +# If there is no PATHRC already set, default to ~/.pathrc +if [ -z "$PATHRC" ]; then + PATHRC=$HOME/.pathrc +fi + +# Similarly, MANPATHRC defaults to ~/.manpath +if [ -z "$MANPATHRC" ]; then + MANPATHRC=$HOME/.manpathrc +fi + +# Set the PATH +if [ -f $PATHRC ]; then + path=() + typeset -U path + for dir in $(<$PATHRC); do + path+=($dir) + done +fi + +# Set the MANPATH +if [ -f $MANPATHRC ]; then + manpath=() + typeset -U manpath + for dir in $(<$MANPATHRC); do + manpath+=($dir) + done +fi