2021-02-13 10:00:50 +01:00
|
|
|
:<<'info'
|
|
|
|
shellnotes - quickread.sh
|
|
|
|
(C) Dimitris Marakomihelakis
|
|
|
|
Released under the "All rights reserved" category. See the RIGHTS.txt file
|
|
|
|
in /docs/github/ for its full text.
|
|
|
|
info
|
|
|
|
|
|
|
|
function quickread() {
|
2021-07-05 14:49:58 +02:00
|
|
|
DIR="$(pwd)"
|
|
|
|
check_params() {
|
2021-07-06 09:56:12 +02:00
|
|
|
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
|
2021-07-06 10:13:45 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Invalid parameter." #"\nUSAGE:\nquickread -r/-s -> FILE\nquickread -l -> LINE, FILE"
|
2021-07-06 09:56:12 +02:00
|
|
|
;;
|
2021-07-05 14:49:58 +02:00
|
|
|
esac
|
|
|
|
return 0
|
|
|
|
}
|
2021-02-13 10:00:50 +01:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo -n "Enter note name: " && read notename
|
2021-07-05 14:49:58 +02:00
|
|
|
elif [ $# -gt 1 ]; then
|
2021-07-06 09:56:12 +02:00
|
|
|
if [ $# -gt 2 ]; then
|
|
|
|
export option=$1
|
|
|
|
export line=$2
|
|
|
|
export notename=$3
|
|
|
|
else
|
2021-07-06 10:13:45 +02:00
|
|
|
export option=$1
|
|
|
|
export notename=$2
|
2021-07-06 09:56:12 +02:00
|
|
|
fi
|
2021-07-05 14:49:58 +02:00
|
|
|
check_params
|
2021-07-06 09:56:12 +02:00
|
|
|
return 0
|
2021-02-13 10:00:50 +01:00
|
|
|
else
|
|
|
|
notename=$1
|
|
|
|
fi
|
2021-07-05 14:49:58 +02:00
|
|
|
|
2021-02-13 10:00:50 +01:00
|
|
|
cd $DEFAULT_PATH
|
|
|
|
if [ -e $notename ]; then
|
2021-07-06 09:56:12 +02:00
|
|
|
# clear
|
2021-07-05 14:49:58 +02:00
|
|
|
if [ "$(cat $notename | wc -l)" -ge 25 ]; then
|
2021-07-05 10:58:11 +02:00
|
|
|
cat $notename | less
|
|
|
|
else
|
|
|
|
cat $notename
|
|
|
|
fi
|
2021-02-13 10:00:50 +01:00
|
|
|
|
|
|
|
else
|
2021-06-15 12:51:22 +02:00
|
|
|
echo "No such note."
|
2021-02-13 10:00:50 +01:00
|
|
|
fi
|
2021-06-15 12:51:22 +02:00
|
|
|
|
2021-04-19 21:20:01 +02:00
|
|
|
cd $DIR
|
2021-02-13 10:00:50 +01:00
|
|
|
}
|