From 1c4ea43278c87f5991a1f47c4c8b9820b2a77295 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 6 Sep 2016 12:51:57 -0700 Subject: [PATCH] Add source_directory_files and use it everywhere --- dotfiles/lib/setup_functions.sh | 7 +++++++ dotfiles/lib/shellenv.sh | 8 +------- dotfiles/lib/shellpath.sh | 6 +++++- dotfiles/lib/shellrc.sh | 4 +--- dotfiles/lib/zsh.sh | 4 +--- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dotfiles/lib/setup_functions.sh b/dotfiles/lib/setup_functions.sh index c224e476..47321fab 100644 --- a/dotfiles/lib/setup_functions.sh +++ b/dotfiles/lib/setup_functions.sh @@ -67,3 +67,10 @@ function environment_variable_exists { function command_exists { hash "$1" 2>/dev/null 1>/dev/null } + +function source_directory_files { + for filename in "$1"/*; do + environment_variable_exists SHELL_STARTUP_DEBUG && echo "Sourcing $filename" + source "$filename" + done +} diff --git a/dotfiles/lib/shellenv.sh b/dotfiles/lib/shellenv.sh index d837a67d..73958245 100644 --- a/dotfiles/lib/shellenv.sh +++ b/dotfiles/lib/shellenv.sh @@ -15,10 +15,4 @@ environment_variable_exists ENVIRONMENT_SETUP_DONE || _setup_env # _ruby_setup _python_setup -function _source_shellenv_files { - for filename in ~/.lib/shellenv/*; do - source $filename - done -} - -_source_shellenv_files +source_directory_files "$HOME/.lib/shellenv" diff --git a/dotfiles/lib/shellpath.sh b/dotfiles/lib/shellpath.sh index f6c51207..c8fcd9f2 100644 --- a/dotfiles/lib/shellpath.sh +++ b/dotfiles/lib/shellpath.sh @@ -5,7 +5,11 @@ function _setup_env { add_to_path "$HOME/.local/bin" "$HOME/.lib/bin" "$HOME/bin" "/usr/local/bin" --before _ruby_setup - _python_setup + + # XXX/TODO: + # This is in shellenv.sh now + # _python_setup + is_osx && _osx_path_setup _emacs_setup _java_setup diff --git a/dotfiles/lib/shellrc.sh b/dotfiles/lib/shellrc.sh index 40e604ac..ea984f4e 100644 --- a/dotfiles/lib/shellrc.sh +++ b/dotfiles/lib/shellrc.sh @@ -1,6 +1,4 @@ -for filename in ~/.lib/shellrc/*; do - source $filename -done +source_directory_files "$HOME/.lib/shellrc" [ -s "/usr/local/bin/virtualenvwrapper.sh" ] && . /usr/local/bin/virtualenvwrapper.sh function j() { diff --git a/dotfiles/lib/zsh.sh b/dotfiles/lib/zsh.sh index d4b35566..14cb171f 100644 --- a/dotfiles/lib/zsh.sh +++ b/dotfiles/lib/zsh.sh @@ -1,6 +1,4 @@ -for filename in ~/.lib/zsh/*; do - source $filename -done +source_directory_files "$HOME/.lib/zsh" alias srczsh="source ~/.zshrc" alias zshenv="source ~/.zshenv"