-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathq
executable file
·50 lines (46 loc) · 1.32 KB
/
q
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
#******************************************************************************
#
# * File: q
#
# * Author: Umut Sevdi
# * Created: 03/15/23
# * Description: Displays a quote or saves one
#*****************************************************************************
[ "$QUOTE_PATH" = "" ] && QUOTE_PATH=$HOME/Documents/quotes
# Set default border size. Border size is 80 or terminal_size
terminal_size=$(tput cols)
Help() {
# Display Help
echo "Quote - Random Quote Displayer"
echo " Picks a random quote from your quote list."
echo "You can add new quotes if you want to"
echo
echo "Syntax: [-h/c|m]"
echo
echo "Options:"
echo "-h/--help Prints this menu."
echo "-a/--add Add a quote to the list."
echo "-A/--author List quotes of the person."
echo
}
for arg in $@; do
if [ "$add" ]; then
echo $arg >> $QUOTE_PATH
exit
elif [ "$author" ]; then
cat $QUOTE_PATH | grep $arg
exit
elif [ $arg = -h ] || [ $arg = --help ]; then
Help
exit
elif [ $arg = -a ] || [ $arg = --add ]; then
add=true
elif [ $arg = -A ] || [ $arg = --author ]; then
author=$arg
else
echo -e "Error: Invalid arguments" 1>&2
exit
fi
done
fold -w $terminal_size <<< $(shuf -n 1 <<< `cat $QUOTE_PATH`)