diff --git a/util/quickread.sh b/util/quickread.sh index 7e43a66..243cd01 100644 --- a/util/quickread.sh +++ b/util/quickread.sh @@ -8,24 +8,38 @@ info function quickread() { DIR="$(pwd)" check_params() { - case $1 in - -parameter | --parameter ) - - ;; + case $option in + -l | --line ) + . ~/.shellnotes/util/quickread/l/l.sh + ;; + -r | --reverse ) + . ~/.shellnotes/util/quickread/r/r.sh + ;; + -s | --sort ) + . ~/.shellnotes/util/quickread/s/s.sh + ;; esac return 0 } if [ $# -eq 0 ]; then echo -n "Enter note name: " && read notename elif [ $# -gt 1 ]; then + if [ $# -gt 2 ]; then + export option=$1 + export line=$2 + export notename=$3 + else + export notename=$3 + fi check_params + return 0 else notename=$1 fi cd $DEFAULT_PATH if [ -e $notename ]; then - clear + # clear if [ "$(cat $notename | wc -l)" -ge 25 ]; then cat $notename | less else diff --git a/util/quickread/l/l.sh b/util/quickread/l/l.sh new file mode 100644 index 0000000..e8463fa --- /dev/null +++ b/util/quickread/l/l.sh @@ -0,0 +1,26 @@ +:<<'info' +shellnotes - l.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info + + + +if [ -f $DEFAULT_PATH/$notename ]; then + + lines="$(cat $DEFAULT_PATH/$notename | wc -l)" + + if [ $line -gt $lines ]; then + echo "There's no such line in this file." + echo "The maximum line number you can use for the specific file is $lines." + elif [ $line -le 0 ]; then + echo "There's no such line in this file." + echo "The minimum line number you can use for a file is 1." + else + sed "${line}q;d" $DEFAULT_PATH/$notename + fi + +else + echo "No such note." +fi diff --git a/util/quickread/r/r.sh b/util/quickread/r/r.sh new file mode 100644 index 0000000..48c3b90 --- /dev/null +++ b/util/quickread/r/r.sh @@ -0,0 +1,6 @@ +:<<'info' +shellnotes - r.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info diff --git a/util/quickread/s/s.sh b/util/quickread/s/s.sh new file mode 100644 index 0000000..3b1bbda --- /dev/null +++ b/util/quickread/s/s.sh @@ -0,0 +1,7 @@ +:<<'info' +shellnotes - s.sh +(C) Dimitris Marakomihelakis +Released under the "All rights reserved" category. See the RIGHTS.txt file +in /docs/github/ for its full text. +info +