2021-01-11 09:12:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-02-10 15:08:13 +00:00
|
|
|
THIS="$(dirname "$(readlink -fm "$0")")"
|
2023-12-14 14:02:45 +00:00
|
|
|
FANCYFY="client"
|
|
|
|
CURRENT_FANCYFY=""
|
2022-02-10 15:02:35 +00:00
|
|
|
DELETE=false
|
|
|
|
MOVE=false
|
2023-12-14 14:02:45 +00:00
|
|
|
PRESENT=false
|
|
|
|
|
|
|
|
_bashrc_present() {
|
2023-12-19 15:54:37 +00:00
|
|
|
if [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
|
2023-12-14 14:02:45 +00:00
|
|
|
echo true
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
echo false
|
|
|
|
}
|
2021-01-11 09:12:48 +00:00
|
|
|
|
2021-03-21 11:13:46 +00:00
|
|
|
_arguments() {
|
2023-12-14 14:02:45 +00:00
|
|
|
if [ "$(_bashrc_present)" = true ]; then
|
|
|
|
PRESENT=true
|
2023-12-19 15:54:37 +00:00
|
|
|
CURRENT_FANCYFY="$(grep TERMINAL_FANCYFY ~/.bashrc | sed 's/.*=//')"
|
2023-12-14 14:02:45 +00:00
|
|
|
fi
|
2021-03-21 11:13:46 +00:00
|
|
|
for PARM in "$@"; do
|
2021-06-03 15:39:45 +00:00
|
|
|
if [ "${PARM}" = "--server" ]; then
|
2023-12-14 14:02:45 +00:00
|
|
|
FANCYFY="server"
|
2022-02-10 15:02:35 +00:00
|
|
|
elif [ "${PARM}" = "--delete" ]; then
|
|
|
|
DELETE=true
|
|
|
|
elif [ "${PARM}" = "--move" ]; then
|
|
|
|
MOVE=true
|
2021-03-21 11:13:46 +00:00
|
|
|
elif [ "${PARM}" = "-h" ] || [ "${PARM}" = "--help" ]; then
|
|
|
|
_help
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
_help() {
|
2021-06-03 15:39:45 +00:00
|
|
|
echo "Usage: $(readlink -fm "$0") [-h | --help] [--cleanup]"
|
2021-03-21 11:13:46 +00:00
|
|
|
echo
|
|
|
|
echo "Options:"
|
2021-08-15 12:37:41 +00:00
|
|
|
echo " -h | --help"
|
|
|
|
echo " Prints this help message and quits"
|
|
|
|
echo " --force"
|
|
|
|
echo " Force the reinstallation of the files"
|
2022-02-10 15:02:35 +00:00
|
|
|
echo " --delete"
|
2023-12-14 14:13:51 +00:00
|
|
|
echo " Delete the reference in ${BASHRC}"
|
2022-02-10 15:02:35 +00:00
|
|
|
echo " --move"
|
|
|
|
echo " Create a new reference if the location of this folder has been changed"
|
2021-08-15 12:37:41 +00:00
|
|
|
echo " --server"
|
|
|
|
echo " Customizes the terminal feel for a server installation"
|
2021-03-21 11:13:46 +00:00
|
|
|
echo
|
2021-01-11 09:12:48 +00:00
|
|
|
}
|
2021-01-11 14:25:38 +00:00
|
|
|
|
2022-02-10 15:02:35 +00:00
|
|
|
_delete() {
|
2023-12-19 15:54:37 +00:00
|
|
|
sed -i '/REF:bashrc_overrides:REF/{N;N;d}' ~/.bashrc
|
2022-02-10 15:02:35 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 12:44:02 +00:00
|
|
|
_bashrc_ref() {
|
2023-12-19 15:54:37 +00:00
|
|
|
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
|
|
|
|
echo "export TERMINAL_FANCYFY=${1}" >> ~/.bashrc
|
|
|
|
echo ". ${THIS}/bashrc_overrides/_all" >> ~/.bashrc
|
2021-03-21 11:13:46 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 15:02:35 +00:00
|
|
|
_move() {
|
|
|
|
_delete
|
2023-12-14 14:07:11 +00:00
|
|
|
_bashrc_ref "${FANCYFY}"
|
2022-02-10 15:02:35 +00:00
|
|
|
}
|
|
|
|
|
2021-03-21 11:13:46 +00:00
|
|
|
_main() {
|
|
|
|
_arguments "$@"
|
|
|
|
|
2022-02-10 15:02:35 +00:00
|
|
|
if [ "${DELETE}" = true ]; then
|
|
|
|
_delete
|
2023-12-14 14:02:45 +00:00
|
|
|
echo "removed custom configs"
|
2022-02-10 15:02:35 +00:00
|
|
|
elif [ "${MOVE}" = true ]; then
|
2023-12-14 14:07:11 +00:00
|
|
|
if [ "${PRESENT}" = false ]; then
|
|
|
|
_bashrc_ref "${FANCYFY}"
|
|
|
|
echo "unable to move to current directory"
|
|
|
|
echo "bash overrides not previously present"
|
|
|
|
echo "adding bash overrides..."
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
_move
|
|
|
|
echo "moved custom config directory to ${THIS}"
|
|
|
|
echo
|
|
|
|
fi
|
2023-12-14 14:02:45 +00:00
|
|
|
elif [ "${PRESENT}" = true ]; then
|
|
|
|
if [ "${CURRENT_FANCYFY}" != "${FANCYFY}" ]; then
|
2023-12-19 15:54:37 +00:00
|
|
|
sed -i "s/TERMINAL_FANCYFY=${CURRENT_FANCYFY}/TERMINAL_FANCYFY=${FANCYFY}/" ~/.bashrc
|
2023-12-14 14:02:45 +00:00
|
|
|
echo "customized fancyfying"
|
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo "bash overrides already in place"
|
|
|
|
echo "skipping..."
|
|
|
|
echo
|
|
|
|
fi
|
2021-03-21 11:13:46 +00:00
|
|
|
else
|
2023-12-14 14:02:45 +00:00
|
|
|
_bashrc_ref "${FANCYFY}"
|
2021-03-21 11:13:46 +00:00
|
|
|
echo "bash overrides added"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_main "$@"
|