work on new parameters for quickread
This commit is contained in:
parent
746ade09e6
commit
4342571adc
4 changed files with 58 additions and 5 deletions
|
@ -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
|
||||
|
|
26
util/quickread/l/l.sh
Normal file
26
util/quickread/l/l.sh
Normal file
|
@ -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
|
6
util/quickread/r/r.sh
Normal file
6
util/quickread/r/r.sh
Normal file
|
@ -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
|
7
util/quickread/s/s.sh
Normal file
7
util/quickread/s/s.sh
Normal file
|
@ -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
|
||||
|
Loading…
Reference in a new issue