From 124efa84cf28340fb2c0dc48eeb330e3696bc541 Mon Sep 17 00:00:00 2001 From: Michael Komitee Date: Sat, 8 Jan 2011 23:21:15 -0500 Subject: [PATCH] Add a plugin to help manage path and manpath * set path based on contents of a PATHRC file defaulting to .pathrc PATHRC file should have one directory per line to set the path * set manpath based on contents of a MANPATHRC file defaulting to .manpathrc MANPATHRC file should have one directory per line to set the manpath --- 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