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")")"
|
2021-06-03 15:45:49 +00:00
|
|
|
SERVER=false
|
2022-02-10 15:02:35 +00:00
|
|
|
DELETE=false
|
|
|
|
MOVE=false
|
2021-01-11 09:12:48 +00:00
|
|
|
|
2021-03-21 11:13:46 +00:00
|
|
|
_arguments() {
|
|
|
|
for PARM in "$@"; do
|
2021-06-03 15:39:45 +00:00
|
|
|
if [ "${PARM}" = "--server" ]; then
|
2021-06-03 15:45:49 +00:00
|
|
|
SERVER=true
|
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"
|
|
|
|
echo " Delete the reference in ~/.bashrc"
|
|
|
|
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() {
|
|
|
|
sed -i '/REF:bashrc_overrides:REF/{N;d}' ~/.bashrc
|
|
|
|
}
|
|
|
|
|
2021-08-15 12:44:02 +00:00
|
|
|
_bashrc_ref() {
|
2021-03-21 11:13:46 +00:00
|
|
|
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
|
2022-02-10 14:06:42 +00:00
|
|
|
echo ". ${THIS}/bashrc_overrides/_all" >> ~/.bashrc
|
2021-03-21 11:13:46 +00:00
|
|
|
}
|
|
|
|
|
2022-02-10 15:02:35 +00:00
|
|
|
_move() {
|
|
|
|
_delete
|
|
|
|
_bashrc_ref
|
|
|
|
}
|
|
|
|
|
2021-03-21 11:13:46 +00:00
|
|
|
_main() {
|
|
|
|
_arguments "$@"
|
|
|
|
|
2022-02-10 15:02:35 +00:00
|
|
|
if [ "${DELETE}" = true ]; then
|
|
|
|
_delete
|
|
|
|
elif [ "${MOVE}" = true ]; then
|
|
|
|
_move
|
|
|
|
elif [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
|
2021-03-21 11:13:46 +00:00
|
|
|
echo "bash overrides already in place"
|
|
|
|
echo "skipping..."
|
|
|
|
echo
|
|
|
|
else
|
2021-08-15 12:44:02 +00:00
|
|
|
_bashrc_ref
|
2021-03-21 11:13:46 +00:00
|
|
|
echo "bash overrides added"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
2021-06-03 15:47:29 +00:00
|
|
|
if [ "${SERVER}" = true ]; then
|
2022-02-10 15:33:07 +00:00
|
|
|
sed -i 's/terminal_fancyfying/terminal_fancyfying_server/' ${THIS}/bashrc_overrides/_all
|
2022-02-10 15:22:29 +00:00
|
|
|
else
|
2022-02-10 15:33:07 +00:00
|
|
|
sed -i 's/terminal_fancyfying_server/terminal_fancyfying/' ${THIS}/bashrc_overrides/_all
|
2021-06-03 15:39:45 +00:00
|
|
|
fi
|
2021-03-21 11:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_main "$@"
|