#!/bin/bash

# .bash_profile
# (loaded for interactive shells)
#
# see alse bashrc file
#
# DO NOT MODIFY THIS FILE DIRECTLY
# USE ~/.metwork.custom_interactive_profile
# TO OVERRIDE

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# We load the "interactive profile"
# shellcheck disable=SC1091
. "/opt/metwork-mfdata-master/share/interactive_profile"

# Specific commands for plugin env
PLUGIN_DIR="${MFDATA_CURRENT_PLUGIN_DIR:-}"
if test "${PLUGIN_DIR}" != ""; then
    if test -L "${PLUGIN_DIR}"; then
        LK=$(readlink -s "${PLUGIN_DIR}" 2>/dev/null)
    else
        LK="${PLUGIN_DIR}"
    fi
    if test "${LK}" != "" -a -d "${LK}"; then
        function custom_cd() {
            if test "$1" = ""; then
                # shellcheck disable=SC2164
                cd "${LK}"
            else
                # shellcheck disable=SC2164
                "cd" "$@"
            fi
        }
        alias cd=custom_cd
        # shellcheck disable=SC2164
        cd "${LK}"
    fi
fi

# We override with custom module wide settings (if existing)
if test -f ~/.metwork.custom_interactive_profile; then
    . ~/.metwork.custom_interactive_profile
fi
