#!/usr/bin/env bashset -eoux pipefailBLING_CLI_DIRECTORY="/usr/share/ublue-os/bling"BLING_SCRIPT_SOURCE=""TARGET_CONFIG_FILE=""shell="$(basename "${SHELL}")"case "${shell}" in"fish")BLING_SCRIPT_SOURCE="bling.fish"TARGET_CONFIG_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/fish/config.fish";;"zsh")BLING_SCRIPT_SOURCE="bling.sh"TARGET_CONFIG_FILE="${ZDOTDIR:-$HOME}/.zshrc";;"bash")BLING_SCRIPT_SOURCE="bling.sh"TARGET_CONFIG_FILE="${HOME}/.bashrc";;*)echo 'Unknown shell. You are on your own.'exit 1;;esacfunction is-bling-installed() {echo "hello"[ -f "$TARGET_CONFIG_FILE" ] || return 1if [ -n "$(grep -n "source $BLING_CLI_DIRECTORY/$BLING_SCRIPT_SOURCE" "$TARGET_CONFIG_FILE" | grep -Eo '^[^:]+')" ]; thenreturn 0fireturn 1}[ -f "${BLING_ENV_SCRIPT:-/usr/share/ublue-os/bling/env.sh}" ] && . "${BLING_ENV_SCRIPT:-/usr/share/ublue-os/bling/env.sh}"BLING_MESSAGE_ENABLE="${BLING_MESSAGE_ENABLE:-Enable bling for ${shell}?}"BLING_MESSAGE_DISABLE="${BLING_MESSAGE_DISABLE:-Disable bling for ${shell}?}"if is-bling-installed "${shell}" ; thengum confirm "${BLING_MESSAGE_DISABLE}"if ! sed -i "/### ${BLING_SCRIPT_SOURCE} source start/,/### ${BLING_SCRIPT_SOURCE} source end/d" "${TARGET_CONFIG_FILE}" ; thensed -i "$(grep -n "source ${BLING_SCRIPT_SOURCE}" "${TARGET_CONFIG_FILE}" | grep -Eo '^[^:]+')"d "${HOME}/.bashrc"fiecho "Bling removed. Reopen your terminal so that the configurations may be removed"elsegum confirm "${BLING_MESSAGE_ENABLE}" --affirmative="Bling me up!" --negative "No, I'm boring"echo "Adding bling to your $(basename "${TARGET_CONFIG_FILE}")"cat<<EOF >> "${TARGET_CONFIG_FILE}"### ${BLING_SCRIPT_SOURCE} source starttest -f ${BLING_CLI_DIRECTORY}/${BLING_SCRIPT_SOURCE} && source ${BLING_CLI_DIRECTORY}/${BLING_SCRIPT_SOURCE}### ${BLING_SCRIPT_SOURCE} source endEOFecho "Installation complete. Reopen your terminal so that the configurations may be applied"fi