]> danix's work - bash-notes.git/commitdiff
added functionality to keep the program open after an operation finishes. This is... master
authorDanilo M. <redacted>
Fri, 15 Aug 2025 08:39:15 +0000 (10:39 +0200)
committerDanilo M. <redacted>
Fri, 15 Aug 2025 08:39:15 +0000 (10:39 +0200)
SOURCE/CORE/helpers.sh
SOURCE/main.sh
notes.sh

index 3f013f28e4c1e6ab6fdaa288fb8f0357827225e9..f0d15d2e260415593b94a87eb3eabd671cf64c2c 100644 (file)
@@ -84,3 +84,10 @@ random_title() {
     echo $OUTPUT
 }
 
+# Keep the application alive until the user decides to exit.
+exitwait() {
+    echo "Press any key to exit.."
+    read -r -n 1
+    exit 0
+}
+
index c2822d9845be72d23e2689a5735effac2a13a3a9..147d90e081d13b54dabea121e8a2635c7f9f0ce0 100644 (file)
@@ -30,25 +30,25 @@ while true; do
                        TITLE=$2
                        shift 2
                        addnote "$TITLE"
-                       exit
+                       exitwait
                ;;
                -e | --edit )
                        NOTE=$2
                        shift 2
                        editnote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -d | --delete )
                        NOTE=$2
                        shift 2
                        rmnote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -s | --show )
                        NOTE=$2
                        shift 2
                        shownote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -r | --restore )
                        RDIR=$2
index a9afd607a1fbb1be68e700ec7b1a35783b093df2..b52a965a023ae049ee40391fedc7daac67d81f25 100755 (executable)
--- a/notes.sh
+++ b/notes.sh
@@ -248,6 +248,13 @@ random_title() {
     echo $OUTPUT
 }
 
+# Keep the application alive until the user decides to exit.
+exitwait() {
+    echo "Press any key to exit.."
+    read -r -n 1
+    exit 0
+}
+
 # check if GITCLIENT has been set or set it to the output of hostname
 if [ -z "$GITCLIENT" ]; then
     GITCLIENT=$( hostname )
@@ -657,25 +664,25 @@ while true; do
                        TITLE=$2
                        shift 2
                        addnote "$TITLE"
-                       exit
+                       exitwait
                ;;
                -e | --edit )
                        NOTE=$2
                        shift 2
                        editnote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -d | --delete )
                        NOTE=$2
                        shift 2
                        rmnote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -s | --show )
                        NOTE=$2
                        shift 2
                        shownote "$NOTE"
-                       exit
+                       exitwait
                        ;;
                -r | --restore )
                        RDIR=$2