From 616e4b6c96c2034c71f46a04f3836b9106343c6f Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Wed, 10 Mar 2021 17:20:19 +0200 Subject: [PATCH] 'au' parameter The auto-update feature. --- util/au/au.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 util/au/au.sh diff --git a/util/au/au.sh b/util/au/au.sh new file mode 100644 index 0000000..e8c9dd6 --- /dev/null +++ b/util/au/au.sh @@ -0,0 +1,30 @@ +:<<'info' +shellnotes - au.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info + +case $1 in -au|--auto-update ) + if grep -q 'ChUpd.sh' ~/.shellnotes/.shellnotes.sh; then + echo "auto-update feature is enabled." + echo -n "Disable it? [Y/N]: " && read input + case $input in Yes|y|Y|yes|YES ) + sed -i '/ChUpd.sh/d' ~/.shellnotes/.shellnotes.sh + echo "auto-update feature is now disabled." + echo "To enable, run 'shellnotes -au' again." + esac + else + echo "auto-update feature is disabled." + echo -n "Enable it? [Y/N]: " && read input + case $input in Yes|y|Y|yes|YES ) + long=$(grep -n "#The lines below must NOT be changed." ~/.shellnotes/.shellnotes.sh) + short=$(echo "${long}" | head -c1) + short=$((short+1)) + file=$(eval echo "~/.shellnotes/util/ChUpd.sh") + sed -i "$short i\. $file" ~/.shellnotes/.shellnotes.sh + echo "auto-update feature is now enabled." + echo "To disable, run 'shellnotes -au' again." + esac + fi +esac