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