From 640e0f2a518fe927aca2ac14b4644c9d83eab8e0 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 25 Feb 2020 21:52:57 +0000 Subject: [PATCH] Allow for grouping pre and post configs --- tag-zsh/zshrc | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/tag-zsh/zshrc b/tag-zsh/zshrc index a5185b3..9fa867c 100644 --- a/tag-zsh/zshrc +++ b/tag-zsh/zshrc @@ -7,13 +7,39 @@ export PATH=$PATH:/usr/local/sbin export PATH=$PATH:"$HOME/.platformsh/bin" export PATH="$HOME/.bin:$PATH" -for zsh_source in $HOME/.zsh/configs/*.zsh; do - source $zsh_source -done - for function in $HOME/.zsh/functions/*; do source $function done +# extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post +# these are loaded first, second, and third, respectively. +_load_settings() { + _dir="$1" + if [ -d "$_dir" ]; then + if [ -d "$_dir/pre" ]; then + for config in "$_dir"/pre/**/*~*.zwc(N-.); do + . $config + done + fi + + for config in "$_dir"/**/*(N-.); do + case "$config" in + "$_dir"/(pre|post)/*|*.zwc) + : + ;; + *) + . $config + ;; + esac + done + + if [ -d "$_dir/post" ]; then + for config in "$_dir"/post/**/*~*.zwc(N-.); do + . $config + done + fi + fi +} +_load_settings "$HOME/.zsh/configs" ensure_tmux_is_running