From c3eaa5bc5336f10f7987843f5851f87388a59c49 Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Thu, 1 Jul 2021 17:55:58 +0300 Subject: [PATCH] ws: View large notes with less --- util/notegrep/ws.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/util/notegrep/ws.sh b/util/notegrep/ws.sh index 67bc605..cc53b47 100644 --- a/util/notegrep/ws.sh +++ b/util/notegrep/ws.sh @@ -5,13 +5,24 @@ Released under the "All rights reserved" category. See the RIGHTS.txt file in /docs/github/ for its full text. info -grepv() {grep -v $regex $DEFAULT_PATH/$notename} #the command run when input is valid +grepv() { #the command run when input is valid + if [ $(grep -v $regex $DEFAULT_PATH/$notename | wc -l) -ge 20 ]; then + grep -v $regex $DEFAULT_PATH/$notename | less + else + grep -v $regex $DEFAULT_PATH/$notename + fi +} nomatch() { echo -n "There are no matches.\nView note anyway?(Y/N): " && read view case $view in y | Y | yes | YES | Yes ) - cat $DEFAULT_PATH/$notename + if [ $(cat $DEFAULT_PATH/$notename | wc -l) -ge 20 ]; then + less $DEFAULT_PATH/$notename + else + cat $DEFAULT_PATH/$notename + fi + return 0 ;; *)