From 5a178299a1b2f6ed58a55fbcb376e0a50a8e0c2f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 20 Nov 2014 23:01:50 -0800 Subject: [PATCH] Make shellenv directory. --- dotfiles/lib/shellenv.sh | 10 +++++++--- dotfiles/lib/{shellrc => shellenv}/emacs.sh | 0 dotfiles/lib/{shellrc => shellenv}/functions.sh | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) rename dotfiles/lib/{shellrc => shellenv}/emacs.sh (100%) rename dotfiles/lib/{shellrc => shellenv}/functions.sh (98%) diff --git a/dotfiles/lib/shellenv.sh b/dotfiles/lib/shellenv.sh index 32a9353f..9f2356a2 100644 --- a/dotfiles/lib/shellenv.sh +++ b/dotfiles/lib/shellenv.sh @@ -1,5 +1,9 @@ -source ~/.lib/shellrc/functions.sh -source ~/.lib/shellrc/emacs.sh +source ~/.lib/shellenv/functions.sh + +for filename in ~/.lib/shellenv/*; do + source $filename +done + function add_to_front_of_path { export PATH=$@:$(echo $PATH | sed "s|:*$@||g" | sed "s|^:||") } @@ -34,6 +38,6 @@ add_to_back_of_path "/usr/local/sbin" # Load RVM into a shell session *as a function* [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" -function shellrc { +function with_shellrc { zsh -c "source ~/.zshrc && ""$@" } diff --git a/dotfiles/lib/shellrc/emacs.sh b/dotfiles/lib/shellenv/emacs.sh similarity index 100% rename from dotfiles/lib/shellrc/emacs.sh rename to dotfiles/lib/shellenv/emacs.sh diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellenv/functions.sh similarity index 98% rename from dotfiles/lib/shellrc/functions.sh rename to dotfiles/lib/shellenv/functions.sh index bcb706ff..28fa98dc 100644 --- a/dotfiles/lib/shellrc/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -1,3 +1,9 @@ +shell_contains () { + local e + for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done + return 1 +} + function dotfiles_directory() { echo $(dirname `readlink -f ~/.zshrc | xargs dirname`) }