From 40cafea102af1cd0fbf597096ced94fa0aceefd8 Mon Sep 17 00:00:00 2001 From: magnu5 Date: Sat, 25 Feb 2012 22:44:13 +0200 Subject: [PATCH] Provide pathmunge for /etc/profile.d scripts --- templates/zshrc.zsh-template | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index e52553241..4db70e53a 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -33,4 +33,38 @@ plugins=(git) source $ZSH/oh-my-zsh.sh +# Provide pathmunge for /etc/profile.d scripts +pathmunge() +{ +if ! echo $PATH | /bin/grep -qE "(^|:)$1($|:)" ; then + if [ "$2" = "after" ] ; then + PATH=$PATH:$1 + else + PATH=$1:$PATH + fi +fi +} + +_src_etc_profile_d() +{ + # Make the *.sh things happier, and have possible ~/.zshenv options like + # NOMATCH ignored. + emulate -L ksh + + + # from bashrc, with zsh fixes + if [[ ! -o login ]]; then # We're not a login shell + for i in /etc/profile.d/*.sh; do + if [ -r "$i" ]; then + . $i + fi + done + unset i + fi +} +_src_etc_profile_d + +unset -f pathmunge _src_etc_profile_d + # Customize to your needs... +