aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRatakor <contact@ratakor.com>2023-03-27 11:08:06 +0200
committerRatakor <contact@ratakor.com>2023-03-27 11:08:06 +0200
commitbd88b4c3bd9441bc01e7f2a7c4014bbf6e40511a (patch)
tree69088571bb3f84aa679ec555bcaaaf4b2e87efef
parent9646656a5e3ac5a5b699548c68cd98b9260d5032 (diff)
add special events, add -p/-f options, sort calendar, increase loop speed
-rw-r--r--README.md14
-rwxr-xr-xquand40
2 files changed, 43 insertions, 11 deletions
diff --git a/README.md b/README.md
index fb6c5bb..06d8d4f 100644
--- a/README.md
+++ b/README.md
@@ -18,11 +18,14 @@ Any line that does not respect the 'yyyy mm dd' format will simply be ignored.
```
# Don't forget the 0 behind month or day
2023 04 28, 07:30 -> 09:30 English
-2023 03 12, Dentist
+2023 03 12 Dentist
-# use a start for events that happen once a year
-* 08 10, Mum's anniversary
-* 07 14, Bastille Day
+# use a star for events that happen once a year
+* 08 10 Mum's anniversary
+* 07 14 Bastille Day
+
+# use 3 stars to always show an event
+* * * Good Morning :)
```
## Configuration
@@ -42,9 +45,12 @@ yesterday="yesterday "
# \033[1m is for bold, it's also possible to add color with for example \033[34m
today="\033[1mtoday "
tomorrow="tomorrow "
+special="special "
+spaces=" " # to align name of months in case today... are too long
mondayfirst=0
```
## TODO
- add a ICS file converter or handle ICS files
- add a man page
+- handle multiple arguments
diff --git a/quand b/quand
index 00f7f3a..7fcdfbe 100755
--- a/quand
+++ b/quand
@@ -12,6 +12,8 @@ future=14
yesterday="yesterday "
today="\033[1mtoday "
tomorrow="tomorrow "
+special="special "
+spaces=" "
mondayfirst=0
getday() {
@@ -19,16 +21,25 @@ getday() {
}
getnameday() {
- LC_ALL="$language" date --date="$1 day" "+%a "
+ LC_ALL="$language" date --date="$1 day" "+%a$spaces"
+}
+
+printspecial() {
+ for line in $calendar; do
+ case $line in
+ "* * *"*)
+ printf "$special\033[m%s\n" "${line#"* * *"}" ;;
+ esac
+ done
}
print() {
- while IFS= read -r line || [ -n "$line" ]; do
+ for line in $calendar; do
case $line in
"$year $1"*|"* $1"*)
- printf "$2\033[m%s\n" "$line" ;;
+ printf "$2\033[m%s\n" "$line" ;;
esac
- done < "$calendar"
+ done
}
@@ -37,12 +48,16 @@ usage() {
Options:
no option | Default
+-h|--help │ Print this help message and exit
+-v|--version | Print the version
+-p|--past | Temporarily change past
+-f|--future | Temporarily change future
|
e|edit | Edit the calendar file
c|cal [n] | Print a calendar with 1 or n months
- │
--h|--help │ Print this help message and exit
--v|--version | Print the version\n' "${0##*/}" 1>&2
+
+Have a look at the README for more information about the configuration.\n' "${0##*/}" 1>&2
+
}
calendar() {
@@ -69,6 +84,12 @@ main() {
c|cal)
calendar "$2"
return ;;
+ -p|--past)
+ past="$2"
+ exec ;;
+ -f|--future)
+ future="$2"
+ exec ;;
'')
exec ;;
*)
@@ -81,6 +102,9 @@ main() {
printf 'Error: %s is not a valid file\n' "$calendar" 1>&2 &&
return 1
+ calendar="$(sort "$calendar")"
+ IFS=$(printf '\n\b')
+
year="$(date "+%Y")" # this is inaccurate
[ "$header" = 1 ] && printf '%s\n\n' "$(LC_ALL="$language" date)"
@@ -103,6 +127,8 @@ main() {
cpt="$((cpt+1))"
done
+ printspecial
+
return 0
}