aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2025-08-15 10:39:15 +0200
committerDanilo M. <danix@danix.xyz>2025-08-15 10:39:15 +0200
commit6c563f788d60acab6947637ea6e05eeef103abd1 (patch)
treeaa33358a47ceca07ce7713eab6657d2d5ed48c1e
parent03d92b35dd555fc08958679e9bf584dacbe14e39 (diff)
downloadbash-notes-master.tar.gz
bash-notes-master.zip
added functionality to keep the program open after an operation finishes. This is particularly useful in transient terminal windows, so that the user can see the output and then close the window by hitting any key.HEADmaster
-rw-r--r--SOURCE/CORE/helpers.sh7
-rw-r--r--SOURCE/main.sh8
-rwxr-xr-xnotes.sh15
3 files changed, 22 insertions, 8 deletions
diff --git a/SOURCE/CORE/helpers.sh b/SOURCE/CORE/helpers.sh
index 3f013f2..f0d15d2 100644
--- a/SOURCE/CORE/helpers.sh
+++ b/SOURCE/CORE/helpers.sh
@@ -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
+}
+
diff --git a/SOURCE/main.sh b/SOURCE/main.sh
index c2822d9..147d90e 100644
--- a/SOURCE/main.sh
+++ b/SOURCE/main.sh
@@ -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
diff --git a/notes.sh b/notes.sh
index a9afd60..b52a965 100755
--- 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