1
0
Files

28 lines
708 B
Bash
Executable File

#!/bin/bash
# This script adds the bin directory to PATH and loads environment variables from .env
#
# Usage:
# Source this script in your rc:
# source /path/to/here/install.sh
# Get script directory for both bash and zsh
if [ -n "$BASH_SOURCE" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
else
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
fi
BIN_DIR="$SCRIPT_DIR/bin"
ENV_FILE="$SCRIPT_DIR/.env"
if [ -d "$BIN_DIR" ]; then
export PATH="$PATH:$BIN_DIR"
fi
if [ -f "$ENV_FILE" ]; then
while IFS='=' read -r key value; do
if [ -n "$key" ] && [ -n "$value" ] && [[ ! "$key" =~ ^# ]]; then
export "$key=$value"
fi
done < "$ENV_FILE"
fi