improved view, fixes

This commit is contained in:
2025-05-23 14:46:56 +02:00
parent 9a5aaea387
commit 2df8fcf1bc

View File

@@ -27,6 +27,12 @@ SED_COLLECTIONLABELS_TO_NAMES=$(
COLLECTION_NAME_MAX_LEN=$(yq '[.collections[].name | length] | max' <"$CONFIGFILE")
LABLES=$(yq '.collections[].label' <"$CONFIGFILE")
SYNC_CMD=$(yq '.sync_cmd' <"$CONFIGFILE")
LONGSPACE=" "
if ! (yq '.collections[].label' | grep ' ') >/dev/null; then
echo "We currently do not support whitespaces in the labels"
exit 1
fi
__vtodopriority() {
python3 -c '
@@ -385,6 +391,8 @@ __filepath_to_searchline() {
totallen=$((maxlen + ${#ROOT} + COLLECTION_NAME_MAX_LEN + 2))
#filepathpad=$(printf "%-${totallen}s" "$filepath")
filepathpad=$(dirname "$filepath")/$(printf "%-${maxlen}s" "$(basename "$filepath")")
collection=$(dirname "$filepath" | sed "s|^$ROOT/*||")
filename=$(basename "$filepath")
# Color support
GREEN=$(printf '\033[1;32m')
@@ -394,7 +402,7 @@ __filepath_to_searchline() {
OFF=$(printf '\033[m')
# Parse file
summary=$(grep '^SUMMARY:' "$filepath" | cut -d ':' -f 2)
summary=$(grep '^SUMMARY:' "$filepath" | cut -d ':' -f 2 | sed 's/\\,/,/g')
categories=$(grep '^CATEGORIES:' "$filepath" | cut -d ':' -f 2)
dtstamp=$(grep '^DTSTAMP:' "$filepath" | cut -d ':' -f 2)
dtstart=$(grep '^DTSTART' "$filepath" | grep -oE '[0-9]{8}')
@@ -445,7 +453,8 @@ __filepath_to_searchline() {
fi
# Print line
echo "$priority $dtstamp $filepathpad $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF"
echo "$priority $dtstamp $collection $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF$LONGSPACE/$filename"
#echo "$priority $dtstamp $filepathpad $date_expr $emoji $prioritymsg$summary_color$summary$OFF $FAINT$categories$OFF"
}
__lines() {
@@ -475,8 +484,9 @@ __lines() {
}
__filepath_from_selection() {
selection=$(echo "$1" | cut -d " " -f 1,2 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT/|")
echo "$selection"
filename=$(echo "$1" | rev | cut -d "/" -f 1 | rev)
dirname=$(echo "$1" | cut -d " " -f 1 | eval "$SED_COLLECTIONLABELS_TO_NAMES" | sed "s|^|$ROOT|")
echo "$dirname/$filename"
}
# Program starts here
@@ -521,7 +531,7 @@ if [ "${1:-}" = "--new" ]; then
file=""
while [ -f "$file" ] || [ -z "$file" ]; do
uuid=$(uuidgen)
file=$(__filepath_from_selection "$collection $uuid.ics")
file=$(__filepath_from_selection "$collection /$uuid.ics")
done
tmpmd=$(mktemp --suffix='.md')
tmpsha="$tmpmd.sha"