new colors and informative git commits

This commit is contained in:
Ämin Baumeler 2025-06-16 14:15:05 +02:00
parent caec86c5a0
commit 9e2e3bc35b
2 changed files with 21 additions and 10 deletions

View File

@ -16,7 +16,7 @@
# @input desc: Event description
# @return: Single-line string
function allday(collection, desc) {
return collection " " ITALIC FAINT " (allday) " OFF desc
return collection " " LIGHT_CYAN ITALIC FAINT " (allday) " OFF CYAN desc OFF
}
# Return line for multi-day event, or event that starts at midnight, which ends today.
@ -26,7 +26,7 @@ function allday(collection, desc) {
# @input desc: Event description
# @return: Single-line string
function endstoday(stop, collection, desc) {
return collection " " CYAN " -- " stop OFF ": " desc
return collection " " LIGHT_CYAN " -- " stop OFF ": " CYAN desc OFF
}
# Return line for event that starts sometime today.
@ -38,9 +38,9 @@ function endstoday(stop, collection, desc) {
# @return: Single-line string
function slice(start, stop, collection, desc) {
if (stop == "00:00")
return collection " " CYAN start " -- " OFF ": " desc
else
return collection " " CYAN start OFF " -- " CYAN stop OFF ": " desc
return collection " " LIGHT_CYAN start " -- " OFF ": " CYAN desc OFF
else
return collection " " LIGHT_CYAN start OFF " -- " LIGHT_CYAN stop OFF ": " CYAN desc OFF
}
# Print line for a single hour entry.
@ -75,6 +75,7 @@ function hrlines(start, stop, h, starth, stoph, tmp, i) {
# AWK program
BEGIN {
FS = "|"
LIGHT_CYAN = "\033[1;36m"
CYAN = "\033[1;36m"
ITALIC = "\033[3m"
FAINT = "\033[2m"

View File

@ -596,8 +596,9 @@ __refresh_data() {
}
###
### UX helper functions
### Helper functions
### __datetime_human_machine
### __summary_for_commit
###
# __datetime_human_machine()
@ -614,6 +615,15 @@ __datetime_human_machine() {
date -d "@$s" +"$dfmt"
}
# __summary_for_commit()
# Get summary string that can be used in for git-commit messages.
#
# @input $1: iCalendar file path
# @req $AWK_GET: Awk script to extract fields from iCalendar file
__summary_for_commit() {
awk -v field="SUMMARY" "$AWK_GET" "$1" | tr -c -d "[:alnum:][:blank:]" | head -c 15
}
###
### iCalendar modification wrapper
###
@ -661,7 +671,7 @@ __edit() {
mv "$filenew" "$fpath"
if [ -n "${GIT:-}" ]; then
$GIT add "$fpath"
$GIT commit -m "Modified event" -- "$fpath"
$GIT commit -m "Modified event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
fi
__refresh_data
else
@ -727,7 +737,7 @@ __new() {
mv "$filenew" "$fpath"
if [ -n "${GIT:-}" ]; then
$GIT add "$fpath"
$GIT commit -m "Added event" -- "$fpath"
$GIT commit -m "Added event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
fi
start=$(awk -v field="DTSTART" "$AWK_GET" "$fpath" | grep -o '[0-9]\{8\}')
else
@ -757,7 +767,7 @@ __delete() {
rm -v "$fpath"
if [ -n "${GIT:-}" ]; then
$GIT add "$fpath"
$GIT commit -m "Deleted event" -- "$fpath"
$GIT commit -m "Deleted event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
fi
break
;;
@ -793,7 +803,7 @@ __import_to_collection() {
mv "$filetmp" "$fpath"
if [ -n "${GIT:-}" ]; then
$GIT add "$fpath"
$GIT commit -m "Imported event" -- "$fpath"
$GIT commit -m "Imported event '$(__summary_for_commit "$fpath") ...'" -- "$fpath"
fi
}