From f87d82f0fdbd0b7f71e2c80017eadfde05c2d31b Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Wed, 6 Aug 2014 13:27:25 +0900 Subject: [PATCH] shrc: avoid multiple source --- shrc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/shrc b/shrc index e005f1e..ef0bcec 100755 --- a/shrc +++ b/shrc @@ -2,6 +2,13 @@ expr "$-" : '^.*i' >/dev/null || return +########################################## + +__shrc_lock=/tmp/shrc_lock.$USER.$$ +test -f "$__shrc_lock" && return +touch "$__shrc_lock" + + ########################################## null(){ "$@" >/dev/null 2>&1 @@ -368,12 +375,12 @@ __safe_alias ipy2=ipython2 # SHELL is set to be /bin/zsh if $inbash then - alias _reloadrc="exec bash" + alias _reloadrc="rm '$__shrc_lock'; exec bash" elif $inzsh then - alias _reloadrc="exec zsh" + alias _reloadrc="rm '$__shrc_lock'; exec zsh" else - alias _reloadrc="exec $SHELL" + alias _reloadrc="rm '$__shrc_lock'; exec $SHELL" fi # alias mytime="date +%Y%m%d-%H%M%S" alias sh="ENV=$HOME/.shrc PS1=\$\ PROMPT_COMMAND="" sh"