dev-env/script/write_aliases
2025-05-25 22:21:05 +02:00

25 lines
672 B
Bash
Executable File

#!/bin/bash
ENV_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd )
CONFIG_FILE="$ENV_DIR/.systems"
source $ENV_DIR/bin/messages
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
errormsg "$CONFIG_FILE not found."
exit 1
fi
echo "" > "$ENV_DIR/.aliases"
# Iterate through all lines in .systems configuration
while IFS=' ' read -r IDENTIFIER DIRECTORY GIT; do
# Skip comments and emtpy lines
if [[ "$IDENTIFIER" =~ ^#.* ]] || [ -z "$IDENTIFIER" ]; then
continue
fi
DIRECTORY="systems/$DIRECTORY"
echo "alias goto-$IDENTIFIER='cd \$DEV_ENV_PATH/$DIRECTORY'" >> "$ENV_DIR/.aliases"
done < "$CONFIG_FILE"