#!/bin/bash
SKIP_POWERSHELL=${SKIP_POWERSHELL:-0};
pushd "${BASH_SOURCE%/*}" > /dev/null;

. "../../Scripts/is-truthy.sh";

if ! grep "\baliae\b" ~/.bashrc > /dev/null
then
    {
        echo '# aliae';
        echo 'eval "$(aliae init bash)"';
        echo "";
    } >> ~/.bashrc;
fi;

if ! isTruthy "${SKIP_POWERSHELL}"
then
    profileFile="$(pwsh -c '$PROFILE')";

    if [ ! -f "$profileFile" ] || ! grep "\baliae\b" "$profileFile" > /dev/null
    then
        install -dm755 "$(dirname "$profileFile")";
        echo "aliae init pwsh | Invoke-Expression" >> "$profileFile";
    fi;
fi;

echo 'aliae init fish | source' | sudo tee /etc/fish/conf.d/aliae.fish > /dev/null;
cp aliae.yml ~/.aliae.yaml;
popd > /dev/null;