added delete and move functions

This commit is contained in:
Bryan Joshua Pedini 2022-02-10 16:02:35 +01:00
parent 2913920987
commit 09cf9b8bbe

View File

@ -2,6 +2,8 @@
SERVER=false
FORCE=false
DELETE=false
MOVE=false
_arguments() {
for PARM in "$@"; do
@ -9,6 +11,10 @@ _arguments() {
SERVER=true
elif [ "${PARM}" = "--force" ]; then
FORCE=true
elif [ "${PARM}" = "--delete" ]; then
DELETE=true
elif [ "${PARM}" = "--move" ]; then
MOVE=true
elif [ "${PARM}" = "-h" ] || [ "${PARM}" = "--help" ]; then
_help
exit 0
@ -24,20 +30,37 @@ _help() {
echo " Prints this help message and quits"
echo " --force"
echo " Force the reinstallation of the files"
echo " --delete"
echo " Delete the reference in ~/.bashrc"
echo " --move"
echo " Create a new reference if the location of this folder has been changed"
echo " --server"
echo " Customizes the terminal feel for a server installation"
echo
}
_delete() {
sed -i '/REF:bashrc_overrides:REF/{N;d}' ~/.bashrc
}
_bashrc_ref() {
echo "#REF:bashrc_overrides:REF" >> ~/.bashrc
echo ". ${THIS}/bashrc_overrides/_all" >> ~/.bashrc
}
_move() {
_delete
_bashrc_ref
}
_main() {
_arguments "$@"
if [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
if [ "${DELETE}" = true ]; then
_delete
elif [ "${MOVE}" = true ]; then
_move
elif [ ! -z "$(grep "#REF:bashrc_overrides:REF" ~/.bashrc)" ]; then
echo "bash overrides already in place"
echo "skipping..."
echo