shellnotes/util/quickread.sh

54 lines
941 B
Bash
Raw Normal View History

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() {
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
;;
esac
return 0
}
2021-02-13 10:00:50 +01:00
if [ $# -eq 0 ]; then
echo -n "Enter note name: " && read notename
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
export notename=$3
fi
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-02-13 10:00:50 +01:00
cd $DEFAULT_PATH
if [ -e $notename ]; then
2021-07-06 09:56:12 +02:00
# clear
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
echo "No such note."
2021-02-13 10:00:50 +01:00
fi
2021-04-19 21:20:01 +02:00
cd $DIR
2021-02-13 10:00:50 +01:00
}