dev-env/script/write_aliases
2024-12-21 03:19:46 +01:00

25 lines
678 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/denv_msg
# Check if .systems configuration exists
if [ ! -f "$CONFIG_FILE" ]; then
denv_error_msg "$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"