From 16219a31db5ca1f8c766d3c6066399950ff7f2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 16 Oct 2015 18:09:36 +0200 Subject: [PATCH] Move broken OS X /etc/zshenv detection to post-up hook This is so it doesn't run every time when zsh starts in interactive mode, but just once per `rcup`. --- hooks/post-up | 27 ++++++++++++++++++++++++++- zshrc | 13 ------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/hooks/post-up b/hooks/post-up index 6df6d9b..5b119ee 100755 --- a/hooks/post-up +++ b/hooks/post-up @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash touch $HOME/.psqlrc.local @@ -7,3 +7,28 @@ if [ ! -e $HOME/.vim/autoload/plug.vim ]; then https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim fi vim -u $HOME/.vimrc.bundles +PlugInstall +PlugClean! +qa + +# detect old OS X broken /etc/zshenv and suggest rename +if grep -qw path_helper /etc/zshenv 2>/dev/null; then + fg_red=$'\e[31m' + fg_bold_white=$'\e[1;37m' + reset_color=$'\e[m' + + # resolve BASH_SOURCE to absolute path + bash_source="$BASH_SOURCE" + if [[ $bash_source == */* ]]; then + pushd "${bash_source%/*}" >/dev/null + bash_source="${PWD}/${bash_source##*/}" + popd >/dev/null + fi + + cat <&2 +${fg_red}Warning:${reset_color} \`/etc/zshenv' configuration file on your system may cause unexpected +PATH changes on subsequent invocations of the zsh shell. The solution is to +rename the file to \`zprofile': + ${fg_bold_white}sudo mv /etc/{zshenv,zprofile}${reset_color} + +(called from ${bash_source}:${LINENO}) + +MSG +fi diff --git a/zshrc b/zshrc index d849590..d930501 100644 --- a/zshrc +++ b/zshrc @@ -111,18 +111,5 @@ _load_settings() { } _load_settings "$HOME/.zsh/configs" -# detect old OS X broken /etc/zshenv and suggest rename -if grep -qw path_helper /etc/zshenv 2>/dev/null; then - cat <&2 -${fg[red]}Warning:${reset_color} \`/etc/zshenv' configuration file on your system may cause unexpected -PATH changes on subsequent invocations of the zsh shell. The solution is to -rename the file to \`zprofile': - ${fg_bold[white]}sudo mv /etc/{zshenv,zprofile}${reset_color} - -(called from ${(%):-%N:%i}) - -MSG -fi - # Local config [[ -f ~/.zshrc.local ]] && source ~/.zshrc.local