From 1bc51ed8ba6e7442a61855073e5d4f10b94f4c74 Mon Sep 17 00:00:00 2001 From: Aviv Ben Shahar Date: Wed, 23 Aug 2023 19:39:24 +0300 Subject: [PATCH] fix: change extends load mechanisem to dynamicly search for extends files and load them --- zsh/.zshrc.extends.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/zsh/.zshrc.extends.sh b/zsh/.zshrc.extends.sh index 03641e1e..051628e4 100644 --- a/zsh/.zshrc.extends.sh +++ b/zsh/.zshrc.extends.sh @@ -2,22 +2,18 @@ echo "extends loaded" -function sourceIf(){ - if [ -f "$1" ]; then - source $1 - fi +function sourceIf() { + if [ -f "$1" ]; then + source $1 + fi } -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.work.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.npm.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.angular.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.nest.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.mongo.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.python.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.redis.sh" -sourceIf "$HOME/shell-config/zsh/extends/.zshrc.extends.git.sh" +function get_all_enabled_files() { + find "$1" -type f -not -name "*.disabled" -print0 | xargs -0 -I {} basename {} | tr '\n' ' ' +} + +files=($(get_all_enabled_files "$HOME/shell-config/zsh/extends")) -# for file in $(ls -a | grep -e ".*\.sh"); do -# echo "source ~/shell-config/extends/zsh/.$file" -# source ~/shell-config/zsh/${file} -# done +for file in "${files[@]}"; do + sourceIf "$rHOME/shell-config/zsh/extends/$file" +done