-
Notifications
You must be signed in to change notification settings - Fork 0
/
load.sh
26 lines (22 loc) · 817 Bytes
/
load.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/zsh
# Directory containing zsh function files
ZSH_FUNCTION_DIR=~/.zsh/functions
# Detect the operating system
OS_TYPE=$(uname)
# Source the .env file if it exists
if [ -f ~/.zsh/.env ]; then
source ~/.zsh/.env
fi
# Source all .sh and .zsh files in the directory and its subdirectories
find $ZSH_FUNCTION_DIR -type f \( -name '*.sh' -o -name '*.zsh' \) | while read file; do
# Check if file is in a platform-specific folder
if [[ "$file" == */mac/* && "$OS_TYPE" != "Darwin" ]]; then
# Skip if file is in mac-specific folder but not on macOS
continue
elif [[ "$file" == */windows/* && "$OS_TYPE" != CYGWIN* && "$OS_TYPE" != MINGW* && "$OS_TYPE" != MSYS* ]]; then
# Skip if file is in windows-specific folder but not on Windows
continue
fi
# Source the file
source "$file"
done