Skip to content

Instantly share code, notes, and snippets.

@lucaswinningham
Created May 19, 2021 18:20
Show Gist options
  • Save lucaswinningham/79d44e8059fa556c994206939accf7df to your computer and use it in GitHub Desktop.
Save lucaswinningham/79d44e8059fa556c994206939accf7df to your computer and use it in GitHub Desktop.
Recursively source bash files
#!/usr/bin/env bash

this_dir="${BASH_SOURCE%/*}"

# Recursively iterates over directories looking for .sh files sourcing them if they exist
for executable in $(find "$this_dir" -regex ".*\.sh"); do
  [ -f "$executable" ] && source "$executable"
done

unset this_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment