From 09cf9b8bbe4fdde3b0f28588ae4d0cb4f2faa40a Mon Sep 17 00:00:00 2001 From: Bryan Joshua Pedini Date: Thu, 10 Feb 2022 16:02:35 +0100 Subject: [PATCH] added delete and move functions --- deploy.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 5b3b8d4..b5fb70f 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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