Skip to content

Commit

Permalink
fix: change extends load mechanisem to dynamicly search for extends f…
Browse files Browse the repository at this point in the history
…iles and load them
  • Loading branch information
Avivbens committed Aug 23, 2023
1 parent 5532fb7 commit 1bc51ed
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions zsh/.zshrc.extends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 1bc51ed

Please sign in to comment.