2021-02-05 19:22:20 +01:00
|
|
|
:<<'info'
|
|
|
|
shellnotes - listnotes.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 listnotes() {
|
2021-07-05 14:49:58 +02:00
|
|
|
DIR="$(pwd)"
|
2021-04-26 08:31:34 +02:00
|
|
|
listnotesFunc () {
|
|
|
|
|
|
|
|
NOTES="`ls $DEFAULT_PATH --color=always `"
|
|
|
|
|
|
|
|
if [ "$NOTES" ]
|
|
|
|
then
|
|
|
|
echo "Your notes from ${DEFAULT_PATH}:\n"
|
|
|
|
echo "$NOTES\
|
|
|
|
|
|
|
|
"
|
2021-02-05 19:22:20 +01:00
|
|
|
fi
|
2021-04-26 08:31:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
-d|--dynamic)
|
|
|
|
. ~/.shellnotes/util/listnotes/d/d.sh
|
|
|
|
;;
|
|
|
|
-n|--number )
|
|
|
|
. ~/.shellnotes/util/listnotes/n/n.sh
|
|
|
|
;;
|
|
|
|
-f|--folder )
|
|
|
|
. ~/.shellnotes/util/listnotes/f/f.sh
|
|
|
|
;;
|
2023-08-21 16:48:30 +02:00
|
|
|
-v|--view )
|
|
|
|
. ~/.shellnotes/util/listnotes/v/v.sh
|
|
|
|
;;
|
2021-04-26 08:31:34 +02:00
|
|
|
*)
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
if [ -z "$(ls -A $DEFAULT_PATH)" ]; then
|
|
|
|
echo "Your Notes folder is empty."
|
|
|
|
else
|
|
|
|
listnotesFunc
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Invalid parameter."
|
|
|
|
fi
|
|
|
|
esac
|
|
|
|
return 0
|
2021-07-05 14:49:58 +02:00
|
|
|
cd $DIR
|
2021-02-05 19:22:20 +01:00
|
|
|
}
|
2023-08-21 16:48:30 +02:00
|
|
|
|
|
|
|
_listnotes_completion() {
|
|
|
|
local cur prev
|
|
|
|
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
|
|
|
|
case "$prev" in
|
|
|
|
listnotes)
|
|
|
|
COMPREPLY=( $(compgen -W "-d -n -f -v" -- "$cur") )
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
complete -F _listnotes_completion listnotes
|