From 45dc8e6bd7e944de612128777c1adaea7138de49 Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Wed, 23 Jun 2021 17:51:16 +0300 Subject: [PATCH] notegrep: "sc" parameter --- util/notegrep.sh | 11 ++++++----- util/notegrep/sc.sh | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 util/notegrep/sc.sh diff --git a/util/notegrep.sh b/util/notegrep.sh index fa5f883..e248f91 100644 --- a/util/notegrep.sh +++ b/util/notegrep.sh @@ -122,8 +122,8 @@ function notegrep() { check_params() { case $option in - parameter) - #parameter script import... + -sc) + . ~/.shellnotes/util/notegrep/sc.sh ;; *) echo "Invalid parameter. Proceeding in normal grep mode." @@ -132,6 +132,7 @@ function notegrep() { esac + return 0 } if [ $# -eq 0 ]; then @@ -139,9 +140,9 @@ function notegrep() { echo -n "Enter note name: " && read notename else if [ $# -eq 3 ]; then - option=$1 - regex=$2 - notename=$3 + export option=$1 + export regex=$2 + export notename=$3 check_params return 0 else diff --git a/util/notegrep/sc.sh b/util/notegrep/sc.sh new file mode 100644 index 0000000..afa58f0 --- /dev/null +++ b/util/notegrep/sc.sh @@ -0,0 +1,22 @@ +:<<'info' +shellnotes - sc.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info + +:<<'vars' +Used from main file: +$option +$regex +$notename +vars + + +out="$(cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | wc -l)" + +if [ $out -gt 20 ]; then + cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g | less +elif [ $out -le 20 ]; then + cat $DEFAULT_PATH/$notename | sed s/$regex/\\n/g +fi